Skip to content

Instantly share code, notes, and snippets.

@ugnelis
Created November 26, 2018 14:08
Show Gist options
  • Save ugnelis/c51b92d1b650487c8c99270f23d2e9de to your computer and use it in GitHub Desktop.
Save ugnelis/c51b92d1b650487c8c99270f23d2e9de to your computer and use it in GitHub Desktop.

Install CUDA and TensorFlow on Linux Mint

Install CUDA

Installation

Install NVIDIA Graphics Driver:

sudo apt-get install nvidia-384 nvidia-modprobe

Download CUDA 9.0:

wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run

Extract 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

Run:

sudo ./cuda-linux.9.0.176-22781540.run
sudo ./cuda-samples.9.0.176-22781540-linux.run

Configure the runtime library:

sudo bash -c "echo /usr/local/cuda/lib64/ > /etc/ld.so.conf.d/cuda.conf"
sudo ldconfig

Open /etc/environment:

sudo nano /etc/environment

Append PATH with :/usr/local/cuda/bin in /etc/environment file.

Install gcc-6 and g++-6 and link them with CUDA:

sudo apt-get install gcc-6 g++-6
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++

Restart the computer:

reboot

Validate Installation

Go to /usr/local/cuda-9.0/samples:

cd /usr/local/cuda-9.0/samples

Run:

sudo make

If there are no errors and just warnings, installation is complete.

Install cuDNN

Go to https://developer.nvidia.com/rdp/cudnn-download.

Press Download cuDNN v7.X.Y, for CUDA 9.0.

Then press to download these selections:

  • cuDNN Runtime Library for Ubuntu16.04 (Deb),
  • cuDNN Developer Library for Ubuntu16.04 (Deb),
  • cuDNN Code Samples and User Guide for Ubuntu16.04 (Deb).

Install downloaded files:

sudo dpkg -i libcudnn7_7.X.Y.Z-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-dev_7.X.Y.Z-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-doc_7.X.Y.Z-1+cuda9.0_amd64.deb

Verify Installation:

Copy cuDNN samples:

cp -r /usr/src/cudnn_samples_v7/ ~

Go to mnistCUDNN folder:

cd ~/cudnn_samples_v7/mnistCUDNN

Compile and run:

make clean && make
./mnistCUDNN

If you see Test passed! at the end of the output then installation is complete.

Install TensorFlow with Anaconda

Download Anaconda from https://www.anaconda.com/download/#linux.

Run installation:

chmod u+x Anaconda3-X.Y.Z-Linux-x86_64.sh
./Anaconda3-X.Y.Z-Linux-x86_64.sh

Close and open terminal.

Create Tensorflow environment for Python 3.6:

conda create -n tensorflow python=3.6

Activate environment:

conda activate tensorflow

Install TensorFlow GPU version

pip install tensorflow-gpu

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment