I am getting a compilation error when trying to compile some code for testing cublas.
This is the error message I am getting:
# pgf90 -Mcuda -o cublas_test cublas_test.cuf -L/opt/cuda/cuda/lib64 -lcublas
/tmp/pgf90tb-5Dhbc8WG.o: In function `.C1_293':
cublas_test.cuf:(.data+0x98): undefined reference to `cublas_'
The contents of the linked library at /opt/cuda/cuda/lib64 are:
# ls /opt/cuda/cuda/lib64/
libcublasemu.so libcublas.so libcudartemu.so libcudart.so libcufftemu.so libcufft.so
libcublasemu.so.3 libcublas.so.3 libcudartemu.so.3 libcudart.so.3 libcufftemu.so.3 libcufft.so.3
libcublasemu.so.3.0.14 libcublas.so.3.0.14 libcudartemu.so.3.0.14 libcudart.so.3.0.14 libcufftemu.so.3.0.14 libcufft.so.3.0.14
Libcublas is definitely present.
I am using the sample code available at CUDA Musing: Calling CUBLAS from CUDA Fortran as it is given there, without any changes.
Am I missing something here?
EDIT: I am attaching the verbose output of the compilation; maybe it helps?
# pgfortran -Mcuda -o cublas_test cublas_test.cuf -L/opt/cuda/cuda/lib64 -lcublas -v
/opt/pgi/linux86-64/10.5/bin/pgf901 cublas_test.cuf -opt 1 -nohpf -nostatic -x 19 0x400000 -quad -x 59 4 -x 59 4 -x 15 2 -x 49 0x400004 -x 51 0x20 -x 57 0x4c -x 58 0x10000 -x 124 0x1000 -x 57 0xfb0000 -x 58 0x78031040 -x 48 4608 -x 49 0x100 -x 120 0x200 -stdinc /opt/pgi/linux86-64/10.5/include:/usr/local/include:/usr/lib/gcc/x86_64-linux-gnu/4.4.4/include:/usr/lib/gcc/x86_64-linux-gnu/4.4.4/include:/usr/include -def unix -def __unix -def __unix__ -def linux -def __linux -def __linux__ -def __NO_MATH_INLINES -def __x86_64__ -def __LONG_MAX__=9223372036854775807L -def '__SIZE_TYPE__=unsigned long int' -def '__PTRDIFF_TYPE__=long int' -def __THROW= -def __extension__= -def __amd64__ -def __SSE__ -def __MMX__ -def __SSE2__ -def __SSE3__ -def __SSSE3__ -freeform -x 137 1 -x 176 1 -vect 48 -x 137 1 -modexport /tmp/pgfortranrWhbZgWmWeBq.cmod -modindex /tmp/pgfortranzWhbl9q-fN5t.cmdx -output /tmp/pgfortranjWhbBR6Ctt7o.ilm
0 inform, 0 warnings, 0 severes, 0 fatal for gemm_test
PGF90/x86-64 Linux 10.5-0: compilation successful
/opt/pgi/linux86-64/10.5/bin/pgf902 /tmp/pgfortranjWhbBR6Ctt7o.ilm -fn cublas_test.cuf -opt 1 -x 51 0x20 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -quad -x 59 4 -x 59 4 -tp nehalem-64 -x 120 0x1000 -x 124 0x1400 -y 15 2 -x 57 0x3b0000 -x 58 0x48000000 -x 49 0x100 -x 120 0x200 -astype 0 -x 124 1 -x 137 1 -x 176 1 -x 137 1 -x 176 1 -cmdline '+pgfortran cublas_test.cuf -Mcuda -o cublas_test -L/opt/cuda/cuda/lib64 -lcublas -v' -asm /tmp/pgfortranHWhbJM4PIPcL.s
0 inform, 0 warnings, 0 severes, 0 fatal for gemm_test
PGF90/x86-64 Linux 10.5-0: compilation successful
/usr/bin/as /tmp/pgfortranHWhbJM4PIPcL.s -o /tmp/pgfortranPWhb7ADTNit0.o
/opt/pgi/linux86-64/10.5/bin/pgappend -noerror /tmp/pgfortranPWhb7ADTNit0.o -name .IPDINFO /tmp/pgfortranrWhbZgWmWeBq.cmod -name .IPEINFO /tmp/pgfortranzWhbl9q-fN5t.cmdx
/usr/bin/ld /usr/lib64/crt1.o /usr/lib64/crti.o /opt/pgi/linux86-64/10.5/lib/trace_init.o /usr/lib/gcc/x86_64-linux-gnu/4.4.4/crtbegin.o /opt/pgi/linux86-64/10.5/lib/f90main.o -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /opt/pgi/linux86-64/10.5/lib/pgi.ld -L/opt/cuda/cuda/lib64 -L/opt/pgi/linux86-64/10.5/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.4 /tmp/pgfortranPWhb7ADTNit0.o -lcublas -rpath /opt/pgi/linux86-64/10.5/lib -rpath /opt/pgi/linux86-64/2010/cuda/2.3/lib -o cublas_test -lcudafor -L/opt/pgi/linux86-64/2010/cuda/2.3/lib -lcudart -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lnspgc -lpgc -lrt -lpthread -lm -lgcc -lc -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.4.4/crtend.o /usr/lib64/crtn.o
/tmp/pgfortranPWhb7ADTNit0.o: In function `.C1_293':
cublas_test.cuf:(.data+0x98): undefined reference to `cublas_'
pgfortran-Fatal-linker completed with exit code 1
Unlinking /tmp/pgfortranjWhbBR6Ctt7o.ilm
Unlinking /tmp/pgfortranrWhbZgWmWeBq.cmod
Unlinking /tmp/pgfortranzWhbl9q-fN5t.cmdx
Unlinking /tmp/pgfortranHWhbJM4PIPcL.s
Unlinking /tmp/pgfortranPWhb7ADTNit0.o