CUDA 7.0 test failed on Ubuntu 14.04
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.
After several trials I finally found the solution. Installation of CUDA is a pain, for which keeps corrupting my system configuration that I have no way to revert.
The solution for the installation must be done in tty1 (the command line) mode, because it needs to kill GUI service before installing NVIDIA drivers, or it will refuse to work. And we need .run
file. With reasons I can't know the .deb files never correctly configure themselves, and I never got them work. look Installing and testing CUDA in Ubuntu 14.04 for a similar solution.
Need to mention, according to my trails:
- installation via apt cannot succeed.
- installation via deb files cannot succeed.
I had the same problem. Running the following command helped me test and understand the problem:
ldd /usr/lib/nvidia-346/libGL.so.346.46
Finally, adding the following to my ~/.profile
solved the problem:
export LD_LIBRARY_PATH=/usr/lib/nvidia-346:$LD_LIBRARY_PATH
as indeed the /usr/lib/nvidia-346
path was not given to the linker.
I too faced the same issue, on Ubuntu 14.04, x86_64 with cuda 7.5. The warnings were:
/usr/bin/ld: warning: libnvidia-tls.so.352.63, needed by /usr/lib/nvidia-352/libGL.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libnvidia-glcore.so.352.63, needed by /usr/lib/nvidia-352/libGL.so, not found (try using -rpath or -rpath-link)
This was the output of ldd /usr/lib/nvidia-352/libGL.so
:
$ ldd /usr/lib/nvidia-352/libGL.so
linux-vdso.so.1 => (0x00007ffc1c5d4000)
libnvidia-tls.so.352.63 =>
libnvidia-glcore.so.352.63 =>
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f161512e000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f1614f1c000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1614b57000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1614952000)
libm.so.6 => /lib/x86_64-linux-(0x00007f1615488000)gnu/libm.so.6 (0x00007f161464c000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f161442d000)
/lib64/ld-linux-x86-64.so.2 (0x0000557aa9c51000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f1614228000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f1614022000)
I added the following line to ~/.zshrc
(~/.bashrc
...if you are using bash):
export LD_LIBRARY_PATH=/usr/lib/nvidia-352:$LD_LIBRARY_PATH
Thus, the following are the entries related to cuda in my ~/.zshrc
:
export PATH=$PATH:/usr/local/cuda-7.5/bin
export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/lib/nvidia-352:$LD_LIBRARY_PATH
Then I sourced ~/.zshrc
source ~/.zshrc
Now ldd /usr/lib/nvidia-352/libGL.so
shows:
linux-vdso.so.1 => (0x00007ffc1c5d4000)
libnvidia-tls.so.352.63 => tls/libnvidia-tls.so.352.63 (0x00007f1617f1c000)
libnvidia-glcore.so.352.63 (0x00007f1615488000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f161512e000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f1614f1c000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1614b57000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1614952000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f161464c000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f161442d000)
/lib64/ld-linux-x86-64.so.2 (0x0000557aa9c51000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f1614228000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f1614022000)
After this the make
inside NVIDIA_CUDA-7.5_Samples
directory completed successfully.