Install CUDA on Ubuntu 16.04

For the record, my graphic card is a GTX 870M.

  1. Install Nvidia recommended drivers. You can find it out by using the command ubuntu-drivers devices. It will tell you the recommended driver you should install via apt-get (I installed nvidia-361).


3.Download CUDA Toolkit from here or Direct link to version 5.7.18 I used

  1. Run the file


Make sure to say yes to everything EXCEPT the prompt that reads:

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 352.39? ((y)es/(n)o/(q)uit): n

  1. Run the tests. Go to the folder you installed the Nvidia tests (default is /~/NVIDIA_CUDA-7.5_Samples). Then change one line (

And do make

You can test by doing nvcc -V

  1. Install Theano

`pip install theano´

  1. Add CUDA PATHS to .bashrc:


  1. Run a theano test. As per theano's Docs, you can use a test file like this:

./cuda_7.5.18_linux.runTHEANOFLAGS="mode=FASTRUN,device=gpu,floatX=float32,nvcc.flags=-DFORCEINLINES" python