A project to start a simple starting project with CUDA
My operating system is Ubuntu 16.04 and the Kernel Release is 4.15.0-120-generic. The command is:
uname -a
The steps for installation was taken from DIX SOFT tutorial and I installed CUDA-8.0.
I'm using CLion and my next problem was similar to this thread.
One solution was to add /usr/local/cuda-/bin to PATH in the /etc/environment configuration file.
After googling this issue, a similar dicussion was found here. The problem is how to change and add the path for all users in /etc/environment
.
The steps that I went through was:
- Copy the current file for backup.
sudo cp /etc/environment /etc/environment.orig
- Edit the existing file
sudo nano -w /etc/environment
Previously, the content wasPATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"$
. It was changed to:PATH="/usr/local/cuda-8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
.
Another error that was encountered was about not being able to find the library directory. Similar to previous step, one solution would be adding the directory for CUDA in a way that all the users and environments have access, i.e. adding it the shared library of the system. This article was useful. The steps were as following:
- Create a new file in /etc/ld.so.conf.d/ called .conf
sudo touch libcuda.conf
- Edit the file and add a line per directory of shared libraries (*.so files)
sudo gedit libcuda.conf
- The following was added to the blank file and saved:
#cuda library
/usr/local/cuda-8.0/lib64
- Reload the list of system-wide library paths:
sudo ldconfig
Up to now, it seems that cudaMalloc takes a lot of time. It is to allocate memory beforehand so that we do not include it in measuring the performance. After cudaMalloc, cudaMemcpy also takes some time which the unnecessary part can be avoided. Other than that, the program seems to be working after all!!