Cuda library link error

I compile both ‘.cuf’ files and ‘.o’ files with
mpif90 -Mcuda -c a.cuf
mpif90 -Mcuda -fast -fastsse -o b.exe ca.o da.o a.o

The error shows that:
/pgi/linux86-64/16.10/lib/ undefined reference to cudaFuncSetSharedMemConfig' /pgi/linux86-64/16.10/lib/ undefined reference to cudaDeviceGetAttribute’
/pgi/linux86-64/16.10/lib/ undefined reference to cudaStreamCreateWithFlags' /pgi/linux86-64/16.10/lib/ undefined reference to cudaStreamCreateWithPriority’
/pgi/linux86-64/16.10/lib/ undefined reference to cudaDeviceSetSharedMemConfig' /pgi/linux86-64/16.10/lib/ undefined reference to cudaStreamGetPriority’
/pgi/linux86-64/16.10/lib/ undefined reference to cudaStreamAttachMemAsync' /pgi/linux86-64/16.10/lib/ undefined reference to cudaDeviceGetSharedMemConfig’
/pgi/linux86-64/16.10/lib/ undefined reference to cudaMallocManaged' /pgi/linux86-64/16.10/lib/ undefined reference to cudaDeviceGetStreamPriorityRange’
pgacclnk: child process exit status 1: /usr/bin/ld

What is the error caused by? How can I solve this problem?
Thank you.

Hi lolilukia23,

As a continuation from what you posted on StackOverflow ( The “-Mcuda” flag will add to the link all necessary CUDA libraries so something else is going on.

A reproducing example would be helpful. If you can, please send one in to PGI Customer Service ( and ask them to send it to me.

If you can’t send in a reproducing example, can you please add the “-v” (verbose) flag to your link, and post the full link command line plus the output. This should tell use if the libraries are indeed being added.

I noticed that on another post on StackOverflow, you asked about using a MPICH build configured for use with GNU with PGI? How did you resolve this issue? MPI should be built and configured for a particular Fortran compiler so you should rebuild MPICH using PGI. Note that we ship a PGI build of MPICH 3.2 with the 16.10 compilers (as well as OpenMPI) which you can find in $PGI/linux86-64/2016/mpi/mpich-3.2.


Hi, Mat
I tried to recreate the problem on my personal computer. But it run successfully with the same environment. I’m totally confused.
The another problem has been solved.Before you replied my e-mail, I used PGI-11.10 with no MPI package. Then I installed PGI-16.10 from the link you sent to me. Then I compiled MPICH with ‘CC=pgcc, FC=pgf90’, so mpicc and mpif90 are linked to PGI.
Many thanks for your kind help.