This tutorial demonstrates how to create a new Project for developing CUDA enabled Apps in NVIDIA GPU platform.
Prerequisites:
- GPU(s) - Geforce, Tesla, etc.
- CUDA SDK - Installed
- CUDA Driver - Installed
- CUDA Toolkit - Installed
- CUDA Samples -Installs with Toolkit
Tutorial
1. Login to GPU Machine (ssh access also fine)
2. Set PATH variable - Add to ~/.bash_profile
- export PATH=$PATH:/usr/local/cuda
/bin
- export PATH=/usr/local/cuda/bin:$
PATH
- export LD_LIBRARY_PATH=$LD_LIBRAR
Y_PATH:/us r/local/cu da/lib
3. Need to add /usr/local/cuda/lib (for 64 bit machines use /usr/local/cuda/lib64) to /etc/ld.so.conf
- Create a File called gpu.conf under /etc/ld.so.conf.d Directory
- Add /usr/local/cuda/lib64 to gpu.conf
4. Run ldconfig as Root user
5. you can Enable Profiler for GPU (optional)
- export CUDA_PROFILE=1
(if you enable cuda profiler and run your main App, you can see a file in the current directory named cuda_profile.log )
Eg:.
Basic Development Environment Setup done!
Hint: On 64-Bit machines cudart ld load error will occur - to fix it try the two steps
- ln -s /usr/local/cuda/lib64/libc
udart.so /usr/lib/libcudart.so
- ln -s /usr/lib64/libXi.so.6 /usr/lib64/libXi.so
Check Installation
- Edit /opt/sample/C/common/commo
n.mk and set the cuda install path /usr/local/cuda
- Go to /opt/sample/C
- run make will compile the samples, if any error persists, check the previous steps
- execute a sample ./opt/sample/C/bin/linux/
release/ba ndwidthTes t(optiona l)
create a New Project (Assumption all the above steps are done successful)
- cd /opt/sample/C/src
- cp template/ yourprojectName -R
- cd yourprojectName
- change the Makefile
(make changes to the yourprojectName.cu file and yourprojectName_kernel.cu file)
- make
Execute the GPU program
- bash ../../bin/linux/release/yo
urprojectN ame
Sample Code:
MakeFile:
Source Code