2

I have tried to compile 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’

As I have already linked the library path in the compilation command, why do I still get the error. Please help me to solve this error.

talonmies
  • 70,661
  • 34
  • 192
  • 269
Newbees
  • 33
  • 7
  • 2
    Usually that sort of linking error would only come up if you were trying to use the (now deprecated) CUBLAS device library. Is that the case here? – talonmies Sep 29 '20 at 07:46
  • 1
    As I have used CUDA 9.0 and CUBLAS library is present in that version .How will I know that CUBLAS library is deprecated or not? – Newbees Sep 29 '20 at 08:21

1 Answers1

2

It seems fairly evident that you are trying to use the CUBLAS library in device code. This is different than ordinary host usage and requires special compilation/linking steps. You need to:

  1. compile for the correct device architecture (must be cc3.5 or higher)
  2. use relocatable device code linking
  3. link in the cublas device library (in addition to the cublas host library)
  4. link in the CUDA device runtime library
  5. Use a CUDA toolkit prior to CUDA 10.0

The following additions to your compile command line should get you there:

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

The above assumes you are actually using a proper install of CUDA 9.0. The CUBLAS device library was deprecated and is now removed from newer CUDA toolkits (see here).

Robert Crovella
  • 143,785
  • 11
  • 213
  • 257
  • Thank you so much for the answer. The prior issue has been solved but now i am getting the following error: /usr/local/cuda-9.0/bin/..//include/cuda_fp16.hpp(1487): error: more than one instance of overloaded function "isinf" matches the argument list: function "isinf(float)" function "std::isinf(float)" argument types are: (float) – Newbees Sep 30 '20 at 05:56