No cuda device code available

Hello! I tried to link a CUDA FORTRAN code with the Fortran code.

I eidt the Makefile as follows:

pgf90 -Mcuda -c bgpu.cuf
OBJS += bgpu.o

CUDALIBS = -L/opt/pgi/linux86-64/15.10/lib -lcudafor -lcudacemu -lcudadevice -lcudafor75 -lcudaforblas -lcudaforemu -lcudapgi
CUDAFLIBS = -L/opt/pgi/linux86-64/2015/cuda/7.5/lib64 -lcublas -lcusparse -lcurand -lcudart -lcufft -lcupti


As you can see, I compiled the bgpu.cuf to bgpu.o, and then I link the bgpu.o object with other object files.

The compilation process was all right. But when I run the EXEC_SE ( that is cesm.exe), I got the error message “libcublas.7.5 no such file or directory” .

So I add the libcublas.7.5 into the LD_LIBRARY_PATH, then I got another message, which is “No CUDA device code available”.

It seems that the program treats the code bgpu.cuf as the F90 file, just because I directly linked the bgpu.o(which was compiled using pgf90) with other .o files(which were compiled from .F90 files using pgf90).

Is there any proper strategy to solve the problem? Thanks

Hi lolilukia,

What compute capability does your device support? (If you don’t know, please post the output from the pgaccelinfo utility).

My best guess is that you have either an older or very new device which 15.10 didn’t support.

Another possibility is that you have a CUDA version mismatch. 15.10 defaults to use CUDA 7.0 but you’re trying to link with the CUDA 7.5 libraries. Try compiling with “-Mcuda=cuda7.5”.

Also, you shouldn’t need to add the CUDA libraries to the link. Plus you’ve added some extraneous one. For example, the “emu” libraries are for emulation mode. For the cuBLAS and other CUDA libraries, use the -Mcudalib flag instead. This way the correct versions will be used.

% pgfortran -help -Mcudalib
                    Add appropriate versions of the CUDA-optimized libraries
% pgfortran -Mcuda=cuda7.5 -Mcudalib=cublas bgpu.o

Another scenario where this can happen is if you are not linking with a PGI compiler. We have to added some kernel registration when the executable loads, and this code is added at link time. If you do need to link with another compiler, then use “-Mcuda=nordc”. The caveat with nordc being that you can call device subroutines to external modules nor use device module data from external modules.

Hope this helps,

1 Like