I followed nvidia official guide to install cuda-7.0, but I had a few problems they didn't provide a complete explanation. And my test samples cannot be built by make
. I'll explain the several mistakes I found during the installation.
environment
I'm working on a 64-bit Ubuntu 14.04, with NVIDIA Corporation GK107 [GeForce GT 640 OEM]
returned by lspci | grep -i nvidia
. My gcc version is 4.4.7.
package
I downloaded from https://developer.nvidia.com/cuda-downloads the "Linux x86 -> Ubuntu 14.04 -> Local Package Installer", which it doesn't provide a md5 value to check. But later the installation was fine as it seems.
installation
I did:
sudo dpkg -i cuda*.deb # returned: OK
sudo apt-get update
sudo apt-get install cuda
test
As official guide said, I have to setup environment path first. I changed to:
cd /usr/local/cuda-7.0
and I can add path:
export PATH=/usr/local/cuda-7.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-7.0/lib64:$LD_LIBRARY_PATH
Here's the first problem: the path is lost whenever I close the terminal. Since I can check it with nvcc -V
where we have nvcc under the first directory.
When I tried to compile the samples:
cd /usr/local/cuda-7.0/samples
sudo make
Finally it returned errors:
make[1]: entering directory `/usr/local/cuda-7.0/samples/2_Graphics/Mandelbrot'
/usr/local/cuda-7.0/bin/nvcc -ccbin g++ -m64 -gencode
arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode
arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode
arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode
arch=compute_52,code=compute_52 -o Mandelbrot Mandelbrot.o Mandelbrot_cuda.o Mandelbrot_gold.o -L../../common/lib/linux/x86_64 -L/usr/lib/"nvidia-346" -lGL -lGLU -lX11 -lXi -lXmu -lglut -lGLEW
/usr/bin/ld: warning: libnvidia-tls.so.346.46, needed by /usr/lib/nvidia-346/libGL.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libnvidia-glcore.so.346.46, needed by /usr/lib/nvidia-346/libGL.so, not found (try using -rpath or -rpath-link)
/usr/lib/nvidia-346/libGL.so:‘_nv018tls’ undefined reference
...
# list of undefined reference
And I cannot go further.
other checks
cat /proc/driver/nvidia/version
doesn't work since/proc/driver
doesn't have the directorynvidia/
./dev/nvidia*
doesn't exits.nvidia-smi
command not found.
These problems exist after reboot.
some fixes
Fixed path and lib settings by adding those two lines under ~/.profile
for current user:
export PATH=/usr/local/cuda-7.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-7.0/lib64:$LD_LIBRARY_PATH
And found a useful link: Installing and testing CUDA in Ubuntu 14.04 it seems I need to install by run file instead.