I finally upgraded from my previous GTX 980 Ti to GTX 1070 last week, unfortunately that meant revisiting some of my previous issues with ubuntu and various incompatibilities among the graphics drivers and cuda components.  In any case I decided this time I will document some of this stuff more cleanly so I can refer to it later.

My Setup:

My previous primary desktop currently re-purposed for machine learning and docker experiments etc..

Hardware:

  • Intel(R) Core(TM) i7-3770K CPU
  • ASUS MAXIMUS IV GENE-Z Motherboard
  • Nvidia GTX 1070

Software:

  • Ubuntu 16.04
  • Nvidia driver 367.35
  • CUDA 8.0 RC
  • Anaconda/Theano/Keras native and as docker containers

Steps:

After replacing the 980 ti card with 1070 I reloaded the machine and it just went into a crash and backtrace loop as the previous nvidia driver nvidia-352 did not support the GTX 1070.

Step one was recovering the system, load into recovery mode, load networking (optional), drop into root shell.

sudo apt-get purge nvidia-*
sudo apt-get autoremove
sudo reboot

This will remove the previous nvidia drivers and dependencies and allow you to do a fresh install of the drivers.

if you haven’t done already make sure you are running  gcc 4.9 to avoid compile errors with Theano

sudo apt-get install gcc-4.9 g++-4.9
sudo ln -s  /usr/bin/gcc-4.9 /usr/bin/gcc -f
sudo ln -s  /usr/bin/g++-4.9 /usr/bin/g++ -f

Download CUDA 8.0 RC, download the runfile(local), when installing cuda 8.0 decline on installing NVIDIA drivers. then reboot.

Install NVIDIA 365.35 drivers

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-367
sudo reboot

At this point you should be able to run nvidia-smi and get some results like this

Thu Aug 4 01:19:40 2016
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 367.35 Driver Version: 367.35 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 1070 Off | 0000:01:00.0 Off | N/A |
| 0% 40C P8 11W / 166W | 103MiB / 8112MiB | 0% Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 4921 C ...y/anaconda3/envs/keras104_py27/bin/python 101MiB |
+-----------------------------------------------------------------------------+

At this point make sure you have the binary and library path’s setup correctly and that nvcc is working fine, adding the following to your .bashrc should do the trick.

export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

nvcc -V should give you

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Wed_May__4_21:01:56_CDT_2016
Cuda compilation tools, release 8.0, V8.0.26

and you should be able to run the example here and get “Used the gpu” as output.

My several hours of research in a 10min post 🙂


12 responses to “GTX 1070 on Ubuntu 16.04 with Cuda 8.0 and Theano”

  1. eneskemalergin Avatar

    Thank you for this helpful post, as you mentioned several hours of searching is unnecessary now 🙂

  2. Andres Avatar
    Andres

    Great Post, thanks for the shortcut!

  3. DrP Avatar
    DrP

    I tried this and it still didn’t seem to work for me 🙁

  4. Sammy Pfeiffer Avatar

    Hello, your post helped me on building this guide on how to dual boot Windows 10 and Ubuntu 14.04 on the new Alienware 15 R3 that has a Nvidia GeForce 1070 GTX. https://github.com/awesomebytes/alienware15r3_ubuntu14 Thank you 🙂

    1. Jay Avatar

      Sammy, thanks for your feedback, glad it was useful to you, btw nice laptop 🙂

  5. Xiaokang Wang Avatar
    Xiaokang Wang

    Hello Jay. Thanks for your documentation. This might be a newbie question. Could you explain how “export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}” works? I know adding a directory to PATH in this way “export PATH=$PATH:~/opt/bin”, but I did not quite get how your command works.

    Thanks.
    Xiaokang

    1. Jay Avatar

      Xiaokang, that’s a great question, the {PATH:+:$PATH}} is bascially is a if:else expression, if PATH variable exists then add “/usr/local/cuda-8.0/bin” to that else set it as the PATH var. see this discussion for more details https://unix.stackexchange.com/questions/267506/what-does-pathpath-mean

  6. Matt Avatar
    Matt

    I have been struggling with this for the past few days. Eventually reached a point where i was considering throwing my entire set up out the window and giving up. This was a godsend. Everything you said worked and I am crying… joyfully crying.

  7. Frank Avatar
    Frank

    Great posting, thank you very much ! That saved me some hours of fiddling around during setup of my new system.

  8. semias Avatar
    semias

    Really great!!
    Thank you so much! You saved me too some hours of search!

    Your post is helpful and perfectly clear!

  9. Kimmo Kivelä Avatar

    Really good, thanks!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.