CUDA cublas, cudart and cusparse library paths

Hi, I am a complete newbie to CUDA and I only started using Ubuntu (18.10) a few weeks ago. I am hoping to use MAGMA for linear algebra, which calls upon the cublas, cusparse and cudart libraries. I have tried using “sudo find -name libcublas*” and done the same for libcudart* and libcusparse*.

When I try to compile and link to the MAGMA example FORTRAN file, if I type into the terminal:

-L/lib/x86_64-linux-gnu -lcublas
-L/usr/local/cuda-10.1/targets/x86_64-linux/lib -lcudart -lcusparse

(as part of a long compile and link procedure) it cannot find the cudart and cusparse libraries.

Please could anyone direct me? I have read countless threads on different fora about library paths and I don’t want to set anything wrong in the /.bashrc

Please could you advise me what I could do?

Try changing this:


to this:


also see here:

Thank you so very much for your speedy reply! I think I must have done something else wrongly because I still get lots of error messages, mostly something like:

/usr/bin/ld: example_f.o: in function MAIN__': example_f.F90:(.text+0x1115): undefined reference to magmaf_init_’
/usr/bin/ld: example_f.F90:(.text+0x123c): undefined reference to magmaf_finalize_' /usr/bin/ld: fortran.o: in function cublas_init_’:
fortran.c:(.text+0x5): undefined reference to `cublasInit’

Please could you tell me if it is a problem with the nvcc installation - or might this be a separate matter from CUDA?

This is a linking issue with some other library or libraries. i.e. its a different issue, and it’s not obvious to me that it is related to CUDA

Thank you so very much for your help.