Install NVIDIA drivers (they were already installed, but it should be as simple as):
sudo apt-get install nvidia-384 nvidia-modprobe
Install CUDA:
Get URL from https://developer.nvidia.com/cuda-downloads
mkdir ~/nvidia-install ; cd ~/nvidia-install
wget -c https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run
chmod +x cuda_9.0.176_384.81_linux-run
./cuda_9.0.176_384.81_linux-run --extract=$HOME/nvidia-install
sudo ./cuda-linux.9.0.176-22781540.run
Add to ~/.bashrc:
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda
source ~/.bashrc
sudo ldconfig
Install CuDNN:
Download runtime and developer library deb's from https://developer.nvidia.com/rdp/cudnn-download
sudo dpkg -i libcudnn7_7.4.1.5-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-dev_7.4.1.5-1+cuda9.0_amd64.deb
Install Tensorflow:
sudo -H pip3 uninstall tensorflow protobuf
sudo -H pip3 install --upgrade tensorflow tensorflow-gpu protobuf
Check setup:
python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000]))); print(tf.__version__)"
Expected output:
2018-11-20 15:49:58.910278: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-11-20 15:49:59.175748: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:964] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-11-20 15:49:59.176888: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 0 with properties:
name: GeForce GTX 1060 6GB major: 6 minor: 1 memoryClockRate(GHz): 1.7715
pciBusID: 0000:01:00.0
totalMemory: 5.93GiB freeMemory: 5.23GiB
2018-11-20 15:49:59.176940: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
2018-11-20 15:49:59.417859: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-11-20 15:49:59.417889: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988] 0
2018-11-20 15:49:59.417909: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0: N
2018-11-20 15:49:59.418092: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4996 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0, compute capability: 6.1)
tf.Tensor(2227.1323, shape=(), dtype=float32)
1.12.0
Refs: