Undefined reference to `cublasCreate_v2’ in '/tmp/tmpxft_0000120b_0000000-10_my_program''

I have tried to run a code using CUDA 9.0 toolkit on NVIDIA Tesla P100 graphic card (Ubuntu version 16.04) and CUBLAS library is used in the code. For compilation, I have used the following command to compile “my_program.cu”

nvcc -std=c++11 -L/usr/local/cuda-9.0/lib64 my_program.cu -o mu_program.o
-lcublas

But, I have got the following error:

nvlink error: Undefined reference to`cublasCreate_v2’in’/tmp/tmpxft_0000120b_0000000-10_my_program’’

I have linked the library path. Still I am getting the error. Please help me to solve this error.

Is this the linking error or compilation?
What does this error mean ?

Thanking You.

Using CUBLAS from device code (which is what you are doing) requires particular compile command line switches. Please study any of the CUDA sample codes in your version of CUDA (i.e. study their Makefile) to discover what is needed.

you will need something like this:

nvcc -std=c++11 -arch=sm_35 -rdc=true my_program.cu -o my_program -lcudadevrt -lcublas_device -lcublas

1 Like

Thank you so much. The error has been resolved.