Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have been trying to get cuda to run on a nvidia gt 650m based laptop. I am running Ubuntu 12.04 with the nvidia 295.59 driver. Also, my laptop uses Optimus so I have install the driver via bumblebee. Bumblebee is not working correctly yet -- however I believe it is possible to install CUDA independently.

To install CUDA I have followed the instructions detailed here: How can I get nVidia CUDA or OpenCL working on a laptop with nVidia discrete card/Intel Integrated Graphics?

However I am still running into problem building the sdk. I made the changes specified at the above link in common.mk, but I got the following (snippet) from the build process:

    make[2]: Entering directory `/home/john/NVIDIA_GPU_Computing_SDK/C/src/fluidsGL'
    /usr/bin/ld: warning: libnvidia-tls.so.302.17, needed by /usr/lib/nvidia-current/libGL.so, not found (try using -rpath or -rpath-link)
    /usr/bin/ld: warning: libnvidia-glcore.so.302.17, needed by /usr/lib/nvidia-current/libGL.so, not found (try using -rpath or -rpath-link)
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv018tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv012glcore'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv017glcore'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv012tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv015tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv019tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv000glcore'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv017tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv013tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv013glcore'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv018glcore'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv022tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv007tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv009tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv020tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv014glcore'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv015glcore'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv016tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv001glcore'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv006tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv021tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv011tls'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv020glcore'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv019glcore'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv002glcore'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv021glcore'
    /usr/lib/nvidia-current/libGL.so: undefined reference to `_nv014tls'
    collect2: ld returned 1 exit status
    make[2]: *** [../../bin/linux/release/fluidsGL] Error 1
    make[2]: Leaving directory `/home/john/NVIDIA_GPU_Computing_SDK/C/src/fluidsGL'
    make[1]: *** [src/fluidsGL/Makefile.ph_build] Error 2
    make[1]: Leaving directory `/home/john/NVIDIA_GPU_Computing_SDK/C'
    make: *** [all] Error 2

The libraries that ld warns about are on my system and are installed on the system:

    $ locate libnvidia-tls.so.302.17 libnvidia-glcore.so.302.17
    /usr/lib/nvidia-current/libnvidia-glcore.so.302.17
    /usr/lib/nvidia-current/libnvidia-tls.so.302.17
    /usr/lib/nvidia-current/tls/libnvidia-tls.so.302.17
    /usr/lib32/nvidia-current/libnvidia-glcore.so.302.17
    /usr/lib32/nvidia-current/libnvidia-tls.so.302.17
    /usr/lib32/nvidia-current/tls/libnvidia-tls.so.302.17

however /usr/lib/nvidia-current and /usr/lib32/nvidia-current are not being picked up by ldconfig. I have tried adding them by adding a file to /etc/ld.so.conf.d/ which gets past this error, however now I am getting the following error:

    make[2]: Entering directory `/home/john/NVIDIA_GPU_Computing_SDK/C/src/deviceQueryDrv'
    cc1plus: warning: command line option ‘-Wimplicit’ is valid for C/ObjC but not for C++ [enabled by default]
    obj/x86_64/release/deviceQueryDrv.cpp.o: In function `main':
    deviceQueryDrv.cpp:(.text.startup+0x5f): undefined reference to `cuInit'
    deviceQueryDrv.cpp:(.text.startup+0x99): undefined reference to `cuDeviceGetCount'
    deviceQueryDrv.cpp:(.text.startup+0x10b): undefined reference to `cuDeviceComputeCapability'
    deviceQueryDrv.cpp:(.text.startup+0x127): undefined reference to `cuDeviceGetName'
    deviceQueryDrv.cpp:(.text.startup+0x16a): undefined reference to `cuDriverGetVersion'
    deviceQueryDrv.cpp:(.text.startup+0x1f0): undefined reference to `cuDeviceTotalMem_v2'
    deviceQueryDrv.cpp:(.text.startup+0x262): undefined reference to `cuDeviceGetAttribute'
    deviceQueryDrv.cpp:(.text.startup+0x457): undefined reference to `cuDeviceGetAttribute'
    deviceQueryDrv.cpp:(.text.startup+0x4bc): undefined reference to `cuDeviceGetAttribute'
    deviceQueryDrv.cpp:(.text.startup+0x502): undefined reference to `cuDeviceGetAttribute'
    deviceQueryDrv.cpp:(.text.startup+0x533): undefined reference to `cuDeviceGetAttribute'
    obj/x86_64/release/deviceQueryDrv.cpp.o:deviceQueryDrv.cpp:(.text.startup+0x55e): more undefined references to `cuDeviceGetAttribute' follow
    collect2: ld returned 1 exit status
    make[2]: *** [../../bin/linux/release/deviceQueryDrv] Error 1
    make[2]: Leaving directory `/home/john/NVIDIA_GPU_Computing_SDK/C/src/deviceQueryDrv'
    make[1]: *** [src/deviceQueryDrv/Makefile.ph_build] Error 2
    make[1]: Leaving directory `/home/john/NVIDIA_GPU_Computing_SDK/C'
    make: *** [all] Error 2

I would appreciate any help that anyone can provide me with. If I can provide any further information please let me know.

Thanks.

share|improve this question
add comment

3 Answers 3

The problem with undefined references to the functions is because you don't link libcuda library using -lcuda. The guide at How can I get nVidia CUDA or OpenCL working on a laptop with nVidia discrete card/Intel Integrated Graphics? mentions that you should remove -lcuda at one place in common.mk, but that did not work for me. But, as the compiler couldn't find the library, it is important to add the directory, where the library is located, so that the corresponding line in common.mk (it is line 276 for me) looks like

    LIB += -L/usr/lib/nvidia-current -lcuda $(RENDERCHECKGLLIB) ${OPENGLLIB} $(PARAMGLLIB) ${LIB}

Similar correction had to be done in the Makefile of the src/deviceQuery folder, last line, changing

    LIB += -lcuda

to

    LIB += -L/usr/lib/nvidia-current -lcuda

Hope that helps!

share|improve this answer
add comment

All I need to do is put the nvidia driver path in the LD_LIBRARY_PATH by doing : export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia-current.

share|improve this answer
add comment

I have the same problem.

I think this question is also related: "cannot find -lOpenCL" error when making the Cuda SDK

To be able to compile the cuda and openCL samples, I did the following.

I followed this guide: How can I get nVidia CUDA or OpenCL working on a laptop with nVidia discrete card/Intel Integrated Graphics? without installing bumblebee and using xswat ppa: https://launchpad.net/~ubuntu-x-swat/+archive/x-updates/

gksudo gedit /etc/environment 
change 
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" 
to 
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/cuda/bin" 

Reload PATH:

source /etc/environment 

Set LD_LIBRARY_PATH:

gksudo gedit /etc/ld.so.conf.d/cuda.conf

Paste into the file: 
/usr/local/cuda/lib64 
/usr/local/cuda/lib 
/usr/lib/nvidia-current
/usr/lib32/nvidia-current

Save and quit the editor. 

Reload LD_LIBRARY_PATH:

sudo ldconfig 

Edited ~/.bash.rc, added:

 export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/lib:/usr/lib/nvidia-current:/usr/lib32/nvidia-current

Reload ~/bash.rc

 source ~/bash.rc

Check whether openCL is found:

    ldconfig -v | grep "OpenCL"

    ...
    libOpenCL.so.1 -> libOpenCL.so.1.0.0
libOpenCL.so.1 -> libOpenCL.so.1.0.0
    ...

Samples should now compile. However don't get your hope up. I think that the nvidia driver is faulty as I get the following error for cuda samples:

[vectorAddDrv] starting...

Vector Addition (Driver API)
checkCudaErrors() Driver API error = 0100 "CUDA_ERROR_INVALID_VALUE" from file <vectorAddDrv.cpp>, line 207.

and for openCL samples:

./oclDeviceQuery 
 [oclDeviceQuery] starting...

 ./oclDeviceQuery Starting...

 OpenCL SW Info:

  Error -1001 in clGetPlatformIDs Call !!!


  !!! Error # -1000 (Unspecified Error) at line 46 , in file oclDeviceQuery.cpp !!!

   Exiting...
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.