Made based on CUDA 9 installation
Download CUDA https://developer.nvidia.com/cuda-downloads Run commands:
sudo dpkg -i cuda-repo-<version>.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda
apt
package is also available if you have blazing fast connection. Otherwise downloadingdeb
is much more efficient especially in case of installation on multiple machines
Validating installation by running deviceQuery
:
cd /usr/local/cuda/extras/demo_suite
./deviceQuery
You should see your GPU CUDA details eg.
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "GeForce 940M"
CUDA Driver Version / Runtime Version 9.0 / 9.0
CUDA Capability Major/Minor version number: 5.0
Total amount of global memory: 2003 MBytes (2100232192 bytes)
( 3) Multiprocessors, (128) CUDA Cores/MP: 384 CUDA Cores
GPU Max Clock rate: 1176 MHz (1.18 GHz)
Memory Clock rate: 900 Mhz
...
Add export scripts in ~/.bashrc
to run it from everywhere:
export CUDA_HOME="/usr/local/cuda"
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH
export PATH="$PATH:$CUDA_HOME/bin"
apply by running source ~/.bashrc
Download 3 cuDNN files https://developer.nvidia.com/rdp/cudnn-download (requires NVIDIA account which can be obtained for free):
- cuDNN Runtime Library for Ubuntu (Deb)
- cuDNN Developer Library for Ubuntu (Deb)
- cuDNN Code Samples and User Guide for Ubuntu (Deb)
We can also install using tarball but it won't include code samples and won't allow us to install
libcupti-dev
which is required by TensorFlow
Validate by running mnistCUDNN
and make sure no error:
cd /usr/src/cudnn_samples_v<version>/mnistCUDNN
sudo make clean && sudo make