CUDA 8.0 and higher versions require at least nvidia-384
driver:
sudo apt-get purge nvidia*
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update && sudo apt-get install nvidia-384 nvidia-settings
By now, you should be able to see your graphics card by entering nvidia-smi
in terminal.
Go to CUDA Toolkit 8.0-Feb 2017 and download the deb(local)
file, then
sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda
You can check the installation using commands below
cd /usr/local/cuda/samples/1_Utilities/deviceQuery #由自己的安装目录决定
sudo make
sudo ./deviceQuery
You should be able to see CUDA version if the installation is successful. Now, configure the environment variables of CUDA:
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda
source ~/.bashrc
Note: If you have installed a higher version of CUDA and want to downgrade to 8.0, the commands below will help you:
sudo apt-get remove cuda
sudo apt autoremove
sudo apt-get autoclean
sudo apt-get install cuda8.0
It is okay to see that CUDA Driver Version = 9.1,CUDA Runtime Version = 8.0
when testing CUDA version.
cuDNN 6.0 (Download Link)
The installation of CuDNN is just copying some files. Hence to check if CuDNN is installed (and which version you have), you only need to check those files. Check where your cuda installation is before installing cuDNN. For most people, it will be /usr/local/cuda/
. You can check it with which nvcc
.
tar -zxvf cudnn-8.0-linux-x64-v6.0.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/ -d
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
Note: If you need a higher version of cuDNN, then register an nvidia developer account and download cudnn here (about 80 MB). You might need nvcc --version
to check your cuda version before downloading compatible cuDNN.
It is pretty easy using pip
:
pip install tensorflow-gpu==1.4.0
For CUDA:
nvcc --version
For cuDNN:
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
For Tensorflow:
[Python Console]
>>> import tensorflow as tf
>>> print(tf.__version__)
1.4.0