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:
http://www.nvidia.com/object/cuda_get.html
(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:
cudadriver_2.3_linux_64_190.18.run
cudatoolkit_2.3_linux_64_ubuntu9.04.run
cudasdk_2.3_linux.run
Installing the NVIDIA driver:
Cuda needs at least version 190 of the linux driver
1.
Uninstall existing NVIDIA drivers and nvidia-glx. (Use gui or aptitude).
2.
Install driver:
Quit x (log out of your desktop, go to a virtual terminal (CTRL+ALT+F1), login, run
$ sudo service gdm stop
3.
Run
$ 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.
4.
Reboot and log back in.
5.
Run
$ nvidia-settings
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.
1.
Run:
$ sudo sh cudatoolkit_2.3_linux_64_ubuntu9.04.run
2.
Press enter to install at the
/usr/local/cuda
default location.
3.
Register the new library files, run:
$ sudo gedit /etc/ld.so.conf.d/cuda.conf
and add
/usr/local/cuda/lib64
to the otherwise empty file and save it. Then run:
$ sudo ldconfig
You can also add
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
to the end of your ~/.bashrc file.
(You should then login and out again of start a new bash with
bash --
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:
1.
Run:
$ sh cudasdk_2.3_linux.run
I chose to install it at the default location.
2.
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
3.
Go to SDK source dir:
cd ~/NVIDIA_GPU_Computing_SDK/C$
4.
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 ..
5.
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
Add
#use gcc-4.3
NVCCFLAGS+=--compiler-bindir=${HOME}/NVIDIA_GPU_Computing_SDK/C/mygcc
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.
6.
You should now be able to compile everything by running
$ make
This should now compile all the examples in the SDK without errors.
Verify Installation
We can now verify that everything is working:
1.
Run:
$ bin/linux/release/deviceQuery
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)
Test PASSED
Press ENTER to exit...
You should now be good to go. Here’s an screenshot of the volumeRender demo:
$ bin/linux/release/volumeRender
Remember to use gcc-4.3/g++-4.3 and the –compiler-bindir option to nvcc when compiling your own CUDA source.


Thomas: Excellent article.
Some question: According of the CUDA_Getting_Started Document.
At the Section 3 of “Installing the CUDA Toolkit” in this post
Where says:
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$PATH
Must say:
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
Hi Carlos,
I am glad you like it.
Yes, that looks like a copy/past error :). It should be fixed now.
Thanks!
Hello Thomas
I had the 190.42 Nvidia driver installed on my Ubuntu machine. After trying to uninstall the 190.42 driver using the synaptic package manager and installing the 190.18 driver using your instructions, I am getting the error:” API mismatch: the client has version 190.18 and the Kernel module has version 190.42″. Since this error occurs at startup no Nvidia driver is installed. Any suggestions on how to roll-back the Kernel to 190.18.
Thanks
Jim
Fixed my problem. Reloaded 190.42 and corrected some path problems. Works fine now.
Thanks
Jim
I am running 64-bit Karmic (kernel version 2.6.31-16-generic) on my workstation with Core i7 920 and GTX285. Before I installed the cuda driver “cudadriver_2.3_linux_64_190.18”, my display along with Compiz effects were working flawlessly with the NVIDIA display driver that I was automatically asked to install right after Ubuntu installation. I later installed cuda driver, toolkit and sdk without any problems and even successfully compiled and run the devicequery example from SDK.
The problem is that now my gdm starts in low-graphics mode complaining that “Failed to initialize the NVIDIA kernel module”. I searched for the error on many forums, but some people are suggesting to editing the config files that I don’t even have.
http://lifeofaprogrammergeek.blogspot.com/…-in-ubuntu.html
http://www.herikstad.net/2009/04/setting-u…-in-ubuntu.html
Somebody suggested to add ServerFlags section to xorg.conf but nothing has worked for me so far.
Section “ServerFlags”
Option “IgnoreABI” “True”
EndSection
Please note that the installation of the driver was successful as I was able to compile and run devicequery example in the console mode. It is only my display that is broken with the CUDA-driver. To further prove my point and be sure of the source of error, I uninstalled the cuda driver and my display and compiz was again up and running even though I kept the new xorg.conf produced by the cuda driver installation. I have uploaded the necessary logs and xorg.conf to help in troubleshooting at NVIDIA forums.
http://forums.nvidia.com/index.php?showtopic=153549
Please help me! Thanks in advance.
Amazing article . …
However for me it was necessary to install the build tools I needed . They didnt come with the default 9.10 .
I did that by :
sudo apt-get install build-essential libglut3-dev -y
Thanks for the article .
Amir, I have the same problem. Did you get it fixed?
*Aamir. Sorry
You forgot sh between sudo and the .run file when installing the driver in step 3.
Nice tutorial, thanks !
Aamir – I had problems when I didn’t uninstall the driver that Ubuntu wanted to install for me before installing the downloaded more recent one. That’s all i can suggest. Uninstall all nvidia drivers, then install the new one.
Also, I’d like to mention you need to install some other stuff before make will work such as mesa-common-dev, freeglut-dev, libXi-dev, and libXmu-dev. These should probably be mentioned.
Thanks so much. I’ve tried doing this for some time now. You’re tutorial finally got me through.
Brilliant! I just had an issue with lXmu but
sudo apt-get install libXmu-dev
fixes it!
Cheers,
B
Hi,
It’s not necessary to use gcc 4.2 to install CUDA and OpenCL on Ubuntu 9.10.
You can just comment out a few lines of source after installing everything, and before building the SDK/examples:
/usr/local/cuda/include/common_functions.h
Comment out the externs for “memset” and “memcopy”.
/usr/local/cuda/include/math_functions.h
Comment out the externs for signbit/signbitl/signbitd/signbitf.
It will now compile with gcc-4.4 (provided you have the right libraries installed, and that LD_LIBRARY_PATH and PATH are set correctly).
David
I followed your guide, as i see others have success, but step 6 in “Installing the CUDA SDK and Compiling the Example Programs” i get the following error with $make:
make[1]: Entering directory `/home/USER/NVIDIA_GPU_Computing_SDK/C/common’
make[1]: Leaving directory `/home/USER/NVIDIA_GPU_Computing_SDK/C/common’
make[1]: Entering directory `/home/USER/NVIDIA_GPU_Computing_SDK/C/common’
make[1]: Leaving directory `/home/USER/NVIDIA_GPU_Computing_SDK/C/common’
make[1]: Entering directory `/home/USER/NVIDIA_GPU_Computing_SDK/C/common’
make[1]: Leaving directory `/home/USER/NVIDIA_GPU_Computing_SDK/C/common’
make -C src/clock/
make[1]: Entering directory `/home/USER/NVIDIA_GPU_Computing_SDK/C/src/clock’
make[1]: Leaving directory `/home/USER/NVIDIA_GPU_Computing_SDK/C/src/clock’
make -C src/marchingCubes/
make[1]: Entering directory `/home/USER/NVIDIA_GPU_Computing_SDK/C/src/marchingCubes’
/usr/bin/ld: cannot find -lXi
collect2: ld returned 1 exit status
make[1]: *** [../../bin/linux/release/marchingCubes] Error 1
make[1]: Leaving directory `/home/USER/NVIDIA_GPU_Computing_SDK/C/src/marchingCubes’
make: *** [src/marchingCubes/Makefile.ph_build] Error 2
Any one that could help me? I don’t know what kind of info you will need, but i have ubuntu 9.10 64bit, GTX275 gpu on p5qdeluxe mb from asus.
See comment number 11 above, you have to install some dependencies.
Hi Thomas, I also follow your guide and have the same problem as Jeans. You already had installed mesa-common-dev, freeglut-dev, libXi-dev, and libXmu-dev. What would be my problem?
make[1]: Entering directory `/home/romulo/NVIDIA_GPU_Computing_SDK/C/common’
make[1]: Leaving directory `/home/romulo/NVIDIA_GPU_Computing_SDK/C/common’
make[1]: Entering directory `/home/romulo/NVIDIA_GPU_Computing_SDK/C/common’
make[1]: Leaving directory `/home/romulo/NVIDIA_GPU_Computing_SDK/C/common’
make[1]: Entering directory `/home/romulo/NVIDIA_GPU_Computing_SDK/C/common’
make[1]: Leaving directory `/home/romulo/NVIDIA_GPU_Computing_SDK/C/common’
make -C src/simpleVoteIntrinsics/
make[1]: Entering directory `/home/romulo/NVIDIA_GPU_Computing_SDK/C/src/simpleVoteIntrinsics’
/usr/include/string.h:43: error: inline function ‘void* memcpy(void*, const void*, size_t)’ cannot be declared weak
/usr/include/string.h:64: error: inline function ‘void* memset(void*, int, size_t)’ cannot be declared weak
/usr/include/bits/string3.h:49: error: inline function ‘void* memcpy(void*, const void*, size_t)’ cannot be declared weak
/usr/include/bits/string3.h:78: error: inline function ‘void* memset(void*, int, size_t)’ cannot be declared weak
/usr/local/cuda/bin/../include/common_functions.h:59: error: inline function ‘void* memset(void*, int, size_t)’ cannot be declared weak
/usr/local/cuda/bin/../include/common_functions.h:62: error: inline function ‘void* memcpy(void*, const void*, size_t)’ cannot be declared weak
/usr/local/cuda/bin/../include/math_functions.h:412: error: inline function ‘int __signbit(double)’ cannot be declared weak
/usr/local/cuda/bin/../include/math_functions.h:417: error: inline function ‘int __signbitf(float)’ cannot be declared weak
/usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbit(double)’ cannot be declared weak
/usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbitf(float)’ cannot be declared weak
/usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbitl(long double)’ cannot be declared weak
/usr/include/bits/mathinline.h:36: error: inline function ‘int __signbitf(float)’ cannot be declared weak
/usr/include/bits/mathinline.h:42: error: inline function ‘int __signbit(double)’ cannot be declared weak
/usr/include/bits/mathinline.h:48: error: inline function ‘int __signbitl(long double)’ cannot be declared weak
/usr/local/cuda/bin/../include/math_functions.h:442: error: inline function ‘int __signbitl(long double)’ cannot be declared weak
make[1]: *** [obj/release/simpleVoteIntrinsics.cu.o] Error 255
make[1]: se sale del directorio `/home/romulo/NVIDIA_GPU_Computing_SDK/C/src/simpleVoteIntrinsics’
make: *** [src/simpleVoteIntrinsics/Makefile.ph_build] Error 2
Sorry, was my mistake. But now I think of a problem…
marxwing@marxwing-laptop:~/NVIDIA_GPU_Computing_SDK/C$ bin/linux/release/deviceQuery
CUDA Device Query (Runtime API) version (CUDART static linking)
There is no device supporting CUDA.
Device 0: “Device Emulation (CPU)”
CUDA Driver Version: 2.30
CUDA Runtime Version: 2.30
CUDA Capability Major revision number: 9999
CUDA Capability Minor revision number: 9999
Total amount of global memory: 4294967295 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: 1
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.35 GHz
Concurrent copy and execution: No
Run time limit on kernels: No
Integrated: Yes
Support host page-locked memory mapping: Yes
Compute mode: Default (multiple host threads can use this device simultaneously)
Test PASSED
Press ENTER to exit…
marxwing@marxwing-laptop:~/NVIDIA_GPU_Computing_SDK/C$ bin/linux/release/volumeRender
[ CUDA 3D Volume Render ]
NVIDIA: could not open the device file /dev/nvidiactl (Permission denied).
freeglut (bin/linux/release/volumeRender): Unable to create direct context rendering for window ‘CUDA volume rendering’
This may hurt performance.
CUDA Capability Major revision number: 9999 , CUDA Capability Minor revision number: 9999 , Warp size: 1, Run time limit on kernels: No …these characteristics are different … would greatly appreciate any help you can provide
Hi! Thank you very much!
I got stuck because I only had g++ 4.4, but your instructions made my day!
Now I’m excited in a disturbing way!! :D
hi ,
I run through all your instruction …but when i run deviceQuery command then got the following error:-
bash: ./deviceQuery: No such file or directory
Please help me get out of this as i have spent so much time on installing CUDA on my ubuntu9.04 machine
Hey Thomas,
I am tryig to install the SDK examples. I already downgraded the gcc and g++ to 4.3. When I try to make, it cannot find -lGL. How should I do to install this library?
Hi,
I am having the same problem as Davi so if either of you have any idea that would be cool.
Thanks
Dean
Interesting. The image looks exactly like http://jcuda.org/samples/Bucky01.png :D
@Davi
@Deab Wood
I run into same problem. Here is the solution I found:
http://kenshin579.tistory.com/entry/Setup-CUDA-31-on-Ubuntu-1004-with-nVidia-Geforce-8400-GS-card
good luck!