Nvfortran ignores LD_LIBRARY_PATH

Compiling a simple CUDA Fortran example (attached):saxpy.txt (841 Bytes) with the HPC SDK Fotran compiler:

$nvfortran saxpy.cuf -lcublas -lcublasLt -lcurand
/usr/bin/ld: cannot find libcublas.so
/usr/bin/ld: cannot find libcublasLt.so
/usr/bin/ld: cannot find libcurand.so
pgacclnk: child process exit status 1: /usr/bin/ld

Math libraries are in the LD_LIBRARY_PATH, still the linker cannot find them. However, explicitly indicating the location with -L, compiles and links perfectly:
$nvfortran saxpy.cuf -L/nvidia/hpcsdk/Linux_x86_64/20.5/math_libs/10.2/lib64/ -lcublas -lcublasLt -lcurand

The SDK does not provide a module for math_libs, however we have created additional modules to loads math_libs so they can complement the compilers.

What are we missing?

L

Hi L.,

Try using the flag “-cudalibs=cublas,curand” instead of adding the CUDA libraries yourself. This is a convenience flag that will include the necessary library path that matches the CUDA version being used.

Note LD_LIBRARY_PATH isn’t used by the linker. It only applies to the loader when finding shared objects at runtime.

-Mat

Hi Mat,

That seems to work well. Thanks for this.

Regards,
Luis

The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.

Hi Mat,

When I try this it states that it isnt allowed arguments:

nvfortran-Error-Switch -cudalibs=cublas allows no arguments

Hi laurjj,

Try using “-cudalib=cublas” (i.e. no “s”) or use just “-cudalibs”. This is my typo above, I should have used “-cudalib”.
“-cubalibs” will include all the available CUDA libraries while “-cudalib=” allows individual selection.

-Mat