NVIDIA’s currently released version of CUDA does not directly with Ubuntu 9.10 which uses GCC 4.4 as the default compiler. However, it is quite easy to make it work and the following guide goes through the entire installation process in some detail.
I use the 64bit version of CUDA, go here to get it:
(I selected Linux 64 bit and Ubuntu 9.04 .)
This lets you download the CUDA Drivers, the CUDA Toolkit and the CUDA SDK, and you will end up with three files:
Installing the NVIDIA driver:
Cuda needs at least version 190 of the linux driver
Uninstall existing NVIDIA drivers and nvidia-glx. (Use gui or aptitude).
Quit x (log out of your desktop, go to a virtual terminal (CTRL+ALT+F1), login, run
$ sudo service gdm stop
$ sudo cudadriver_2.3_linux_64_190.18.run
to install the driver, follow the prompts.
Say yes to install 32 bit compatibility libraries.
If you want you can let the installer overwrite the Xorg configuration file.
Reboot and log back in.
to verify that your driver version is at least 190.18. Look for the driver version in the window:
Installing the CUDA Toolkit:
After having installed the driver we now need to install the CUDA toolkit itself.
$ sudo sh cudatoolkit_2.3_linux_64_ubuntu9.04.run
Press enter to install at the
Register the new library files, run:
$ sudo gedit /etc/ld.so.conf.d/cuda.conf
to the otherwise empty file and save it. Then run:
$ sudo ldconfig
You can also add
to the end of your ~/.bashrc file.
(You should then login and out again of start a new bash with
to update your environment.
Installing the CUDA SDK and Compiling the Example Programs
We will now install the CUDA SDK to your own home directory so you can play with the supplied demos:
$ sh cudasdk_2.3_linux.run
I chose to install it at the default location.
As CUDA does not yet work with GCC 4.4 you will have to install gcc-4.3:
$ sudo aptitude install gcc-4.3 g++-4.3
Go to SDK source dir:
Create a directory and create symlinks to gcc-4.3/g++-4.3
$ mkdir mygcc
$ cd mygcc
$ ln -s $(which g++-4.3) g++
$ ln -s $(which gcc-4.3) gcc
$ cd ..
Edit common makefile:
$ gedit common/common.mk
Find the lines that specify CC, CXX and LINK and change them to:
CXX := g++-4.3
CC := gcc-4.3
LINK := g++-4.3 -fPIC
Before the line that says “ifeq ($(nvcc_warn_verbose),1)”. This tells the nvcc computer that it should look in mygcc for gcc, which will cause it to pickup our gcc-4.3 compiler.
You should now be able to compile everything by running
This should now compile all the examples in the SDK without errors.
We can now verify that everything is working:
On my machine I get the following output (depending on your harware, you ourput may be different):
CUDA Device Query (Runtime API) version (CUDART static linking)
There is 1 device supporting CUDA
Device 0: "GeForce 8800 Ultra" CUDA Driver Version: 2.30 CUDA Runtime Version: 2.30 CUDA Capability Major revision number: 1 CUDA Capability Minor revision number: 0 Total amount of global memory: 804585472 bytes Number of multiprocessors: 16 Number of cores: 128 Total amount of constant memory: 65536 bytes Total amount of shared memory per block: 16384 bytes Total number of registers available per block: 8192 Warp size: 32 Maximum number of threads per block: 512 Maximum sizes of each dimension of a block: 512 x 512 x 64 Maximum sizes of each dimension of a grid: 65535 x 65535 x 1 Maximum memory pitch: 262144 bytes Texture alignment: 256 bytes Clock rate: 1.51 GHz Concurrent copy and execution: No Run time limit on kernels: Yes Integrated: No Support host page-locked memory mapping: No Compute mode: Default (multiple host threads can use this device simultaneously)
Press ENTER to exit...
You should now be good to go. Here’s an screenshot of the volumeRender demo:
Remember to use gcc-4.3/g++-4.3 and the –compiler-bindir option to nvcc when compiling your own CUDA source.