Skip to content

Instantly share code, notes, and snippets.

@EvGe22
Last active March 26, 2018 13:59
Show Gist options
  • Save EvGe22/dbf23a4ed49d6558f081b11f4f56a56c to your computer and use it in GitHub Desktop.
Save EvGe22/dbf23a4ed49d6558f081b11f4f56a56c to your computer and use it in GitHub Desktop.
Installing Tensorflow 1.6 with CUDA 9.0 with cudnn 7.0 on Ubuntu 16.04 x86_64 | Anaconda

Useful links:

Step 1

Make sure you have a Nvidia GPU that supports CUDA. You can do it by running these:

  1. update-pciids - updates the description of the hardware
  2. lspci | grep -i nvidia - find all nvidia hardware you have
  3. Check if you model has the CUDA support by searching for it here

Check your linux version by running uname -m && cat /etc/*release

Verify you have gcc installed by running gcc --version

Check your kernel version and update kernel headers:

  1. uname -r
  2. sudo apt-get install linux-headers-$(uname -r)

Step 2

Install CUDA and drivers:

  1. Go to CUDA download page
  2. Download all the files
  3. Install all packages in the historical order by running sudo dpkg -i <package_file>
  4. Run sudo apt-get update
  5. Run sudo apt-get install cuda-9-0 as your last step
  6. Make sure you have installed CUDA 9.0 and not CUDA 9.1 by running nvcc --version
  7. If you've installed 9.1 then remove it by running sudo apt-get remove cuda and run sudo apt-get install cuda-9-0

Step 3

Install cuDNN:

  1. Go to cuDNN download page
  2. If you have an account then log in or sign up
  3. Download the deb runtime package
  4. install it by running sudo dpkg -i <package_file>

Step 4

Install Tensorflow 1.6 with GPU support. There are two ways of installing it:

  1. By installing from the direct link

    1. Go to this section of the official Tensorflow installation guide and choose your link, copy it
    2. Run pip install --ignore-installed --upgrade <copied_link>
  2. By using official pip repo

    1. Run pip install tensorflow-gpu

Step 5

Verify the installation.

Run python and use this little program to see if the installation is correct

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

You should see b'Hello, TensorFlow!' written in the console

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