CUDA10 on Ubuntu 18.04
With a previous installation of CUDA9 I wrote code for my GPU against CUDA directly, but mostly using TensorFlow and Keras. To upgrate to CUDA10, I heard that Anaconda was a quicker way to install the dependencies, including cuDNN. It was relatively simple, but required manual installation of the latest libraries - at least on Ubuntu.
First, find the version you want to install and its md5sum. They're listed here, and I'm using the latest (March 2019) values for Linux.
wget https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh
echo '43caea3d726779843f130a7fb2d380a2 Anaconda3-2019.03-Linux-x86_64.sh' | md5sum -c
# If hash was OK, install
bash ./Anaconda3-2019.03-Linux-x86_64.sh
Towards the end of the installation, you'll be informed that:
==> For changes to take effect, close and re-open your current shell. <==
If you'd prefer that conda's base environment not be activated on startup,
set the auto_activate_base parameter to false:
conda config --set auto_activate_base false
Finally, to install the required libraries - including cuda and cuDNN (versions 10.0.130 and 7.3.1 for the above installation):
(base) iain@iain-ubuntu:~$ conda install keras tensorflow-gpu
If you've already installed a previous version of the CUDA libraries, you might have a problem with conflicts.
python -c "from keras import backend as b; b.tensorflow_backend._get_available_gpus()"
Fails with tensorflow.python.framework.errors_impl.InternalError: cudaGetDevice() failed. Status: CUDA driver
version is insufficient for CUDA runtime version
The solution is to install the latest drivers from NVIDIA. Once complete, the latest versions installed are reported for me as:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.56 Driver Version: 418.56 CUDA Version: 10.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 106... Off | 00000000:01:00.0 On | N/A |
| 0% 51C P0 30W / 120W | 314MiB / 6077MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
And the available devices now include the GPU:
2019-04-17 12:22:41.466674: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115]
Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4509 MB memory)
-> physical GPU
(
device: 0,
name: GeForce GTX 1060 6GB,
pci bus id: 0000:01:00.0,
compute capability: 6.1
)
⁂