Install the required build tools
CUDA 4.0 does not support gcc 4.5+, I seemed to already have gcc 4.6 installed on my instance. There is no problem with having multiple versions of gcc installed side-by-side, we just have to install the 4.4 versions.
$ sudo apt-get install build-essential gcc-4.4 g++-4.4
Download the SDKs
Download the CUDA Toolkit for Ubuntu (the 10.10 version) and the GPU Computing SDK from here http://developer.nvidia.com/cuda-toolkit-40
These weigh in at around 210Mb and 140Mb respectively.
Install the CUDA Toolkit:
The CUDA Toolkit needs to be installed as root.
$ chmod 755 cudatoolkit_4.0.17_linux_64_ubuntu10.10.run
$ sudo ./cudatoolkit_4.0.17_linux_64_ubuntu10.10.run
Once you have completed installing this, add the CUDA bin location to your path - I did this in my .bashrc .
export PATH=$PATH:/usr/local/cuda/bin
And now you need to add the CUDA libs to your library search path, I already had the nvidia_settings.conf file here, though you can add any file with a .conf extension. The lines added are in bold.
$ cat /etc/ld.so.conf.d/nvidia_settings.conf
/usr/lib/nvidia-settings
/usr/local/cuda/lib64
/usr/local/cuda/libNow run ldconfig to pick up the changes.
$ sudo ldconfig
Install the GPU SDK
Much like the CUDA Toolkit, though this does not need to be installed by root, it defaults to ~/NVIDIA_GPU_Computing_SDK .
$ chmod 755 gpucomputingsdk_4.1.21_linux.run
$ ./gpucomputingsdk_4.1.21_linux.run
Link the 4.4 compilers
If you have multiple gcc versions installed, we need to make sure that nvcc (the CUDA compiler) picks up the 4.4 version. This can be done through flags for nvcc, however we need a link for it called gcc and g++.
Create a new directory in your home, called gcc-4.4 and create a link in here to the 4.4 version of gcc and g++.
$ cd
$ mkdir gcc-4.4
$ cd gcc-4.4
$ ln -s /usr/bin/g++-4.4 g++
$ ln -s /usr/bin/gcc-4.4 gcc
Set the compiler flag in the provided samples
In order to build the supplied samples we now need to modify the supplied MakeFile.
$ cd ~/NVIDIA_GPU_Computing_SDK/C/common
$ vim common.mk
Find a line that looks like:
NVCCFLAGS :=
And change it to look like:
NVCCFLAGS := -ccbin ~/gcc-4.4/
This flag tells nvcc where to find the gcc and g++ compilers.
Make the sample - deviceQuery
We will build the deviceQuery sample, this sample prints output of our CUDA device.
$ cd ~/NVIDIA_GPU_Computing_SDK/C/src/deviceQuery
$ make
$ cd ~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release
$ ./deviceQuery
You should now see the output of the deviceQuery sample.
Using nvcc
You will need to use the -ccbin flag if you wish to use nvcc from the commandline, though this is quite easy:
$ nvcc -ccbin ~/gcc-4.4 my_app.cu
Hello!
ReplyDeleteFirst thanks a lot, I really had a hard time trying to understand how to use nvcc...
but when i did the make in deviceQuerry i got 2 errors:
/usr/bin/ld: cannot find -lshrutil_x86_64
/usr/bin/ld: cannot find -lcuda
collect2: ld returned 1 exit status
do you know what it could be? I'm using Ubuntu11.10 with unity
thank you very much
Hello!
DeleteIt's me again!
in fact i've to do:
$ export PATH=&PATH:/usr/local/cuda/bin
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
before compiling with nvcc.
It's maybe due to a mistake from me, but it's working that way!
Thank you for your help!
Guillaume (I still don't know why google dosen't want me to give my firstName...)
root@kumbo:~/NVIDIA_GPU_Computing_SDK/C/src/deviceQuery# make
ReplyDeletecc1plus: attention : command line option ‘-Wimplicit’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from ../../common/inc/cutil_inline.h:20:0,
from deviceQuery.cpp:24:
../../common/inc/cutil_inline_runtime.h:472:13: attention : unused parameter ‘argc’ [-Wunused-parameter]
../../common/inc/cutil_inline_runtime.h:472:13: attention : unused parameter ‘argv’ [-Wunused-parameter]
/usr/bin/ld: cannot find -lcutil_x86_64
/usr/bin/ld: cannot find -lshrutil_x86_64
/usr/bin/ld: cannot find -lcuda
collect2: ld a retourné 1 code d'état d'exécution
make: *** [../../bin/linux/release/deviceQuery] Erreur 1
please i need help for this list of error. I am on ubuntu 11.10
Now i have this following errors. Please help
ReplyDeleteI run on ubuntu 11.10
root@kumbo:~/NVIDIA_GPU_Computing_SDK/C/src/deviceQuery# make
/usr/bin/ld: cannot find -lcuda
collect2: ld a retourné 1 code d'état d'exécution
make: *** [../../bin/linux/release/deviceQuery] Erreur 1
you need to change the commands :
Deleteexport PATH=$PATH:/usr/local/cuda/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
by
export PATH=$PATH:/usr/local/cuda/bin:$LD_LIBRARY_PATH>>~/.profile
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64:$LD_LIBRARY_PATH>>~/.profile
it will make save the path to your profile so you can reuse it, otherway you should have to rewrite the exprot every time.
I ran a long time before finding out^^
Hi,
DeleteI am getting 3 errors :
/usr/bin/ld: cannot find -lcutil_i386
/usr/bin/ld: cannot find -lshrutil_i386
/usr/bin/ld: cannot find -lcuda
collect2: ld returned 1 exit status
make: *** [../../bin/linux/release/deviceQuery] Error 1
I did the changes you specified in my .bashrc file but the error didn't change.It may be because of some problem in using nvcc. Plz help....
Hi,
DeleteI got the same 3 errors as you:
/usr/bin/ld: cannot find -lcutil_i386
/usr/bin/ld: cannot find -lshrutil_i386
/usr/bin/ld: cannot find -lcuda
The first two I have solved adding this to the .bashrc file:
export LPATH=/usr/lib/nvidia-current:$LPATH
export LIBRARY_PATH=/usr/lib/nvidia-current:$LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/lib/nvidia-current:/usr/local/cuda/lib64:/usr/local/cuda/lib:$LD_LIBRARY_PATH
And the last one (/usr/bin/ld: cannot find -lcuda) I have solved creating a ln as you can see here:
sudo ln -s /usr/lib/nvidia-current/libcuda.so /usr/lib/libcuda.so
Probably you could solve the first two also creating a ln, but I am not sure (neither I tried).
Enjoy!!
Hi,
DeleteThanks for the reply.....I did what you said but it still didn't resolve.
Also when I do make in NVIDIA_GPU_Computing_SDK/ it gives me the following errors :
make -C src/smokeParticles/
make[2]: Entering directory `/home/apoorv/NVIDIA_GPU_Computing_SDK/C/src/smokeParticles'
/usr/bin/ld: cannot find -lGL
/usr/bin/ld: cannot find -lGLU
/usr/bin/ld: cannot find -lX11
/usr/bin/ld: cannot find -lXi
/usr/bin/ld: cannot find -lXmu
/usr/bin/ld: cannot find -lglut
collect2: ld returned 1 exit status
make[2]: *** [../../bin/linux/release/smokeParticles] Error 1
make[2]: Leaving directory `/home/apoorv/NVIDIA_GPU_Computing_SDK/C/src/smokeParticles'
make[1]: *** [src/smokeParticles/Makefile.ph_build] Error 2
make[1]: Leaving directory `/home/apoorv/NVIDIA_GPU_Computing_SDK/C'
make: *** [all] Error 2
Someone suggested me to resolve these for proper funtioning but I don't know the exact libraries which have to be installed.......Plz help...
This comment has been removed by the author.
ReplyDelete