Installing CUDA 7.5 on Ubuntu 15.10 (nvidia 960M)

1. Install nvidia-drivers and reboot

sudo apt-get install nvidia-352-updates nvidia-modprobe
sudo reboot

2. Download the deb file from

3. Install it using the following commands

sudo dpkg -i cuda-repo-ubuntu1504-7-5-local_7.5-18_amd64.deb 
sudo apt-get update
sudo apt-get install cuda

4. Add these lines to ~/.bashrc

export PATH=/usr/local/cuda-7.5/bin/:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:$LD_LIBRARY_PATH

5. Configure runtime library

sudo bash -c "echo /usr/local/cuda/lib64/ > /etc/"
sudo ldconfig

6. Since Ubuntu 15.10 comes with gcc/g++ of 5.2 version. We have to make cuda work with it, by default it won't. Some people suggest to install 4.9 and to link it with cuda-7.5. But this will cause linker issues in future reference1 reference2

7. Edit header file host_config.h

gedit /usr/local/cuda/include/host_config.h

as shown below, Comment line 115.

#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9)

//#error -- unsupported GNU version! gcc 4.10 and up are not supported!                                       

#endif /* __GNUC__> 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9) */

8. duplicate and compile cuda samples

rsync -av /usr/local/cuda/samples .

cd samples

make -j4

9. Run the sample example nbody simulation

cd 5_Simulations/nbody
./nbody -benchmark -numbodies=256000

Working with theano and cuda

1. Install Theano

sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libopenblas-dev git
sudo pip install Theano

2. Add the following code to

from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy
import time

vlen = 10 * 30 * 768  # 10 x #cores x # threads per core
iters = 1000

rng = numpy.random.RandomState(22)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], T.exp(x))
t0 = time.time()
for i in range(iters):
    r = f()
t1 = time.time()
print("Looping %d times took %f seconds" % (iters, t1 - t0))
print("Result is %s" % (r,))
if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]):
    print('Used the cpu')
    print('Used the gpu')

3. See if gpu is used or not


4. If not create a file ~/.theanorc with the following code

ldflags =

floatX = float32
device = gpu

# By default the compiled files were being written to my local network drive.
# Since I have limited space on this drive (on a school's network),
# we can change the path to compile the files on the local machine.
# You will have to create the directories and modify according to where you 
# want to install the files. 
# Uncomment if you want to change the default path to your own.
# base_compiledir = /local-scratch/jer/theano/

fastmath = True

cxxflags = -ID:\MinGW\include

# Set to where the cuda drivers are installed.
# You might have to change this depending where your cuda driver/what version is installed.

4. Now run


You should see "gpu is used"

Installing Caffe

Issue of hd5:


just modify the Makefile.config 
    +INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
    +LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/

Installing Digits

Issue of latlas Install libatlas-base-dev

sudo apt-get install libatlas-base-dev

Tensorflow with GPU

If you have to configure to different version of cuda then build from sources, else you could install directly

1. Clone latest tensorflow

git clone

1a. Install coreutils using brew

ruby -e "$(curl -fsSL"


brew install coreutils

2. Configure depending on your cuda and other needs after going into cloned directory


3. Build with bazel (gpu)

bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

CPU only

bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

If you haven't installed bazel

sudo apt-get install software-properties-common swig

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java8-installer

echo "deb stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list

curl | sudo apt-key add -

sudo apt-get update

sudo apt-get install bazel 

4. Install Tensorflow pip package

bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

sudo pip install /tmp/tensorflow_pkg/tensorflow-1.1.0rc1-cp27-cp27mu-linux_x86_64.whl

5. Upgrade Protobuf

sudo pip install --upgrade

Wiki: mallasrikanth/cuda (last edited 2017-04-17 15:24:49 by mallasrikanth)