0

I have a GTX TITAN on which I would use the Dynamic Parallelism.

I did some tests by adding "-rdc = true" and the flag "-lcudadevrt" but I always get a linking error when compiling.

This is my Makefile:

DEP                     =       main.o Optimizer.o cudaOptimizer.o
CUDA_INSTALL_PATH       = /usr/local/cuda
INC_CUDA                = -I$(CUDA_INSTALL_PATH)/include
LIB_CUDA                = -L$(CUDA_INSTALL_PATH)/lib64 -lcuda -lcudart -lcublas -lcublas_device -lcudadevrt

optx: $(DEP)
    g++ $(LIB_CUDA) -o optx $(DEP)

main.o:
    g++ $(INC_CUDA) -c main.cpp

Optimizer.o:
    g++ $(INC_CUDA) -c Optimizer.cpp

cudaOptimizer.o:
    nvcc --compiler-options '-fPIC -O3' -arch sm_35 -c cudaOptimizer.cu -rdc=true

This is the out:

g++ -I/usr/local/cuda/include -c main.cpp
g++ -I/usr/local/cuda/include -c Optimizer.cpp
nvcc --compiler-options '-fPIC -O3' -arch sm_35 -c cudaOptimizer.cu -rdc=true
g++ -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcublas_device -lcudadevrt -o optx main.o Optimizer.o cudaOptimizer.o
cudaOptimizer.o: In function`__sti____cudaRegisterAll_48_tmpxft_00003942_00000000_6_cudaOptimizer_cpp1_ii__Z4ciaov()':tmpxft_00003942_00000000-3_cudaOptimizer.cudafe1.cpp:(.text.startup+0x1d): undefined reference to `__cudaRegisterLinkedBinary_48_tmpxft_00003942_00000000_6_cudaOptimizer_cpp1_ii__Z4ciaov'
collect2: error: ld returned 1 exit status
make: *** [optx] Error 1

How can I solve this problem?

Thanks

4

1 回答 1

2

您正在与 g++ 链接。

必须与 nvcc 链接,因为您正在进行设备代码链接,而 g++ 不知道设备代码。

于 2013-10-11T22:16:26.913 回答