Skip to content

CUDA Installation

Jonathan Balloch edited this page Apr 4, 2017 · 14 revisions

Introduction

At long last, I have managed to get a CUDA installation working reliably alongside our ROS environments without breaking things (so far). Here are the steps you need to take:

Prep

Of course you need to make sure that you have the essentials

sudo apt-get install build-essential

Before we begin purge all drivers from your computer. This is important so as to not have any residual libraries

sudo apt-get purge nvidia-*

Download new drivers by going to the CUDA download area and download the CUDA 8.0 '.run' drivers for Debian/Ubuntu. It should be of the style:

cuda_7.5.18_linux.run

Separately extract new CUDA and nVidia drivers:

mkdir ~/Downloads/nvidia_installers;
cd ~/Downloads
./cuda_7.5.18_linux.run -extract=~/Downloads/nvidia_installers;

"Blacklisting" the nouveau file will make it so that nothing goes unstable from its removal, but will never be used while you have an nVidia driver. Create the file that will do this by creating a file called /etc/modprobe.d/blacklist-nouveau.conf and filling it with the two lines: blacklist nouveau and option nouveau modset=0. You can do this with the following commands:

sudo cat /etc/modprobe.d/blacklist-nouveau.conf
echo "blacklist nouveau" >> /etc/modprobe.d/blacklist-nouveau.conf
echo "options nouveau modset=0" >> /etc/modprobe.d/blacklist-nouveau.conf

Add this to your machine's driver list:

sudo update-initramfs -s

For all commands from this point forward we will be operating in a headless mode. Please print these instructions or pull them up on another machine

Installing the drivers and CUDA

Restart your computer. nothing should have changed, but the image of your login screen may look distorted with nouveau blacklisted and no current nVidia driver. Type Alt+Ctrl+F1 to change to headless mode. You should be presented with a tty terminal. Login with your usual username and password, and then navigate to the directory we created.

cd ~/Downlaods/nvidia_installers

Turn off display manager:

sudo service lightdm stop

This is incredibly important. Building with --no-opengl-files is necessary for this to work as far as I have found

Run the driver script (where the asterisks should be the numbers of the driver in this folder; tab autocaomplete should find it):

sudo ./NVIDIA-Linux-x86_64-3**.**.run --no-opengl-files

Next install the toolkit:

sudo ./cuda-linux64-rel-*.*.**-********.run
sudo ./cuda-sample-linux-*.*.**-********.run

Add your new environmental variables to your PATH and export them to your .bashrc:

export PATH=/usr/local/cuda-8.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH
echo "export PATH=/usr/local/cuda-8.0/bin:$PATH" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH" >> ~/.bashrc

Verify that your driver was installed correctly:

cat /proc/driver/nvidia/version

Verify CUDA version

nvcc -v

Now at this point you can restart your Display Manager

sudo service lightdm start.

Now build and run a sample for testing:

cd /usr/local/cuda/sample/1_Utilities/deviceQuery
sudo make
./deviceQuery

If this works and shows a CUDA Capable device you are done!

(Largely sourced from here)

Clone this wiki locally