I’ve heard a lot about CUDA, such as how it is 10,000% faster at cracking wireless passwords over a conventional program/hardware, but never really got around to testing it out before now. This post details the steps required to compile and setup CUDA 2.3 SDK and toolkit on ubuntu 9.10.
Downloads
You are required to have an Nvidia graphics driver (relatively new version) already installed. First download the CUDA toolkit and CUDA sdk from the Nvidia CUDA 2.3 download page.
Install the toolkit
# Make file executable chmod +x cudatoolkit_2.3_linux_64_ubuntu9.04.run # Run it as superuser sudo ./cudatoolkit_2.3_linux_64_ubuntu9.04.run
You now need to edit your .bashrc file in your home directory to include the paths (so your CUDA binaries can be found by the system)
export PATH=${PATH}:/usr/local/cuda/bin export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib64
Note if you are using 32bit then “lib64” should be replaced with just “lib”
Install the SDK
# Make file executable chmod +x cudasdk_2.3_linux.run # Run it as normal user ./cudasdk_2.3_linux.run
You should now have a NVIDIA_GPU_Computing_SDK folder in your home directory. Change directory into the C folder inside this one.
cd NVIDIA_GPU_Computing_SDK/C
In this folder is a make file which will compile all the Nvidia SDK and all the demos, in order for this to work in ubuntu 9.10 (x64) you will need to install several dependencies. By installing these before attempting to make will save you a lot of time, if you are getting errors please scroll down to the problems section to see if they are already covered.
# Install the necessary libraries sudo apt-get install freeglut3 freeglut3-dev libx11-dev mesa-common-dev libxmu6
Making and running demos
You can then run the make command, once this is ran all of the executables will be placed in NVIDIA_GPU_Computing_SDK/C/bin/linux/released . We can check that our computer has an useable CUDA device install by running the deviceQuery program:
cd ~/NVIDIA_GPU_Computing_SDK/C/bin/linux/released ./deviceQuery
This should output something similar to the following:
# ./deviceQuery CUDA Device Query (Runtime API) version (CUDART static linking) There is 1 device supporting CUDA Device 0: "GeForce GTX 260" CUDA Driver Version: 2.30 CUDA Runtime Version: 2.30 CUDA Capability Major revision number: 1 CUDA Capability Minor revision number: 3 Total amount of global memory: 938803200 bytes Number of multiprocessors: 27 Number of cores: 216 Total amount of constant memory: 65536 bytes Total amount of shared memory per block: 16384 bytes Total number of registers available per block: 16384 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.47 GHz Concurrent copy and execution: Yes Run time limit on kernels: Yes Integrated: No Support host page-locked memory mapping: Yes Compute mode: Default (multiple host threads can use this device simultaneously) Test PASSED
Now that we can see CUDA is successfully installed and a suitable device is found we can run some of nvidia’s more ascetically pleasing demos:
./fluidsGL
./smokeParticles
./particles
./postProcessGL
Problems
libxi (Nvidia forum link) make[1]: Leaving directory `/home/mat/NVIDIA_GPU_Computing_SDK/C/common' make[1]: Entering directory `/home/mat/NVIDIA_GPU_Computing_SDK/C/common' In file included from ./../common/inc/paramgl.h:24, from src/paramgl.cpp:19: ./../common/inc/GL/glut.h:60:20: error: GL/glu.h: No such file or directory make[1]: *** [obj/release/paramgl.cpp.o] Error 1 make[1]: Leaving directory `/home/mat/NVIDIA_GPU_Computing_SDK/C/common' make: *** [lib/libparamgl.so] Error 2
sudo apt-get install freeglut3 freeglut3-dev libx11-dev mesa-common-dev
/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/particleSystem.cu.o] Error 255 make[1]: Leaving directory `/home/mat/NVIDIA_GPU_Computing_SDK/C/src/particles' make: *** [src/particles/Makefile.ph_build] Error 2
The problem is due to having gcc 4.4 installed rather than 4.3, it is possible to install the older version of this compiler but it is simpler to modify common/common.mk and add the following extra flag (Nvidia forum link):
# Change: NVCCFLAGS += --compiler-options -fno-strict-aliasing # To: NVCCFLAGS += --compiler-options -fno-strict-aliasing --compiler-options -fno-inline
and change the -O2
# Change: COMMONFLAGS += -O2 # To: COMMONFLAGS += -O0
The two remaining errors you may encounter are very similar and arrise from missing libraries:
libxi (Nvidia forum link)
/usr/bin/ld: cannot find -lXi collect2: ld returned 1 exit status make[1]: *** [../../bin/linux/release/particles] Error 1
sudo apt-get install libxi-dev
libxmu (Nvidia forum link)
/usr/bin/ld: cannot find -lXmu collect2: ld returned 1 exit status make[1]: *** [../../bin/linux/release/particles] Error 1
sudo apt-get install libxmu-dev libxmu6
That has to be one of the best video’s I’ve seen yet =]
Finally a solution to my headache..thanks a lot!!!
thanks for this bud!
Great step by step. Thanks!
I’m running Lucid Lynx (10.4), 64-bit, on a Lenovo T61p with a Quadro FX 570m. The walkthrough worked almost perfectly. The examples were compiled up to and including MersenneTwister. matrixMulDrv didn’t link correctly: ‘/bin/ld: cannot find -lcuda’. The compiled examples work nicely, though.
I forgot to say: excellent walkthrough nevertheless; very detailed and helpful.
Thanks for your comments, I had fun getting this working 🙂
@Ravi I don’t know what’s going on with Lucid Lynx but I plan to upgrade soon, so I might find out what’s going on.
Thanks a lot for the excellent tutorial.
I also don’t get -lcuda in Lucid. Anything peculiar or is it normal?
[…] First install CUDA, most places will tell you that CUDA is incompatible with gcc-4.3 but this is not true if you make a few small changes to the configuration.mk file, please see this post about installing CUDA in ubuntu […]
Hi Mat, great tutorial, it has been really useful. About the problem with Lucid Lynx I have solved it. The problem is that the file /usr/lib/libcuda.so doesn’t exist. But if you situate in the / directory and execute find . -name “libcuda*”, you will find it. So the only thing you have to do is make a link to this file in the /usr/lib directory: ln -s /usr/lib/nvidia-current/libcuda.so.256.35 libcuda.so (in my case).
I hope it will help some people. Sorry for my english 🙂
@matri Thanks!
Nice! Thank you.
Thanks for the instructions. They’re better than you find on the websites
Thanks Mat. That helped me a lot. I am able to run deviceQuery and a few other programs. Yet, I cannot build all the executables.
make -C src/recursiveGaussian/ gives me the following error:
/usr/bin/ld: cannot find -lGL
Same for all the examples with graphics.
Do you know which package I am missing?
My config: Ubuntu 10.10. GeForce 9500M.
Got it: needed to reinstall libgl1-mesa-glx, and then reinstall the nvidia driver again.
Hi there is a program to see the reflection of particles from gold and diamonds and can the particles be treated to 3D images I am willing to pay $ 10,000 for it