Trouble building with Dynamic Parallelism on Nsight Eclipse

I’m having great difficulties compiling a project where I am trying to use dynamic parallelism.

I have a K20C card and have the project set up to build for compute capability 3.5
In NSight Eclipse under the project settings I have selected to link with -lcudadevrt
I also have select to compile with the -fPIC

Here is the build command and output I initially got on the file causing trouble(the one where I am using dynamic parallelism):

Building file: …/src/PCG_Kernels.cu
Invoking: NVCC Compiler
nvcc -G -g -O0 -Xcompiler -fPIC -gencode arch=compute_35,code=sm_35 -odir “src” -M -o “src/PCG_Kernels.d” “…/src/PCG_Kernels.cu”
nvcc --compile -G -O0 -Xcompiler -fPIC -g -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35 -x cu -o “src/PCG_Kernels.o” “…/src/PCG_Kernels.cu”

ptxas fatal : Unresolved extern function ‘cudaGetParameterBuffer’
make: *** [src/PCG_Kernels.o] Error 255

To fix this I opened the file specific settings and modified nvcc command to be invoked like this: nvcc -dc -gencode arch=compute_35,code=sm_35

This changes the build command for this file to be:

Building file: …/src/PCG_Kernels.cu
Invoking: NVCC Compiler
nvcc -G -g -O0 -Xcompiler -fPIC -gencode arch=compute_35,code=sm_35 -odir “src” -M -o “src/PCG_Kernels.d” “…/src/PCG_Kernels.cu”
nvcc -dc -gencode arch=compute_35,code=compute_35 -G -g -O0 -Xcompiler -fPIC “src/PCG_Kernels.o” “…/src/PCG_Kernels.cu”

Finished building: …/src/PCG_Kernels.cu

But then the linker stage has some issues!

Building target: libIPM_Dynamic
Invoking: NVCC Linker
nvcc -shared -link -o “libIPM_Dynamic” ./src/Main.o ./src/Manager.o ./src/Matrix.o ./src/PCG.o ./src/PCG_Kernels.o ./src/Vector.o ./src/matlabInterface.o -lpthread -lcudadevrt -lhdf5 -lz -lmatio
g++: ./src/PCG_Kernels.o: No such file or directory

I’ve spent about 3 hours trying to build this – I must be missing something, any ideas?

You need to enable the separate compilation mode.

  1. In project properties, on CUDA property page, enable separate compilation
  2. Delete your output folder (e.g. Debug) and rebuild the project