我维护C+=-flavored CUDA API wrappers库。该库的当前提交经过了相对良好的测试,其中包含一些示例程序和许多用户。但是,在最近的某个时间(无法确切说出何时),并且没有提交任何新内容,我现在在示例程序的“ dlink”阶段收到NVCC警告,例如:

/path/to/nvcc /path/to/cuda-api-wrappers/examples/modified_cuda_samples/vectorAdd/vectorAdd.cu -dc -o /path/to/cuda-api-wrappers/CMakeFiles/vectorAdd.dir/examples/modified_cuda_samples/vectorAdd/./vectorAdd_generated_vectorAdd.cu.o -ccbin /opt/gcc-5.4.0/bin/gcc -m64 -gencode arch=compute_52,code=compute_52 --std=c++11 -Xcompiler -Wall -O3 -DNDEBUG -DNVCC -I/path/to/cuda/include -I/path/to/cuda-api-wrappers/src
/path/to/nvcc -gencode arch=compute_52,code=compute_52 --std=c++11 -Xcompiler -Wall -O3 -DNDEBUG -m64 -ccbin /opt/gcc-5.4.0/bin/gcc -dlink /export/path/to/cuda-api-wrappers/CMakeFiles/vectorAdd.dir/examples/modified_cuda_samples/vectorAdd/./vectorAdd_generated_vectorAdd.cu.o /path/to/cuda/lib64/libcublas_device.a -o /export/path/to/cuda-api-wrappers/CMakeFiles/vectorAdd.dir/./vectorAdd_intermediate_link.o
@O@ptxas info    : 'device-function-maxrregcount' is a BETA feature
@O@ptxas info    : 'device-function-maxrregcount' is a BETA feature
@O@ptxas info    : 'device-function-maxrregcount' is a BETA feature
... this repeats many times ...


但是dlink的脸确实可以得出结论。这已经很奇怪了,因为我还没有明确使用任何beta功能。

/opt/gcc-5.4.0/bin/g++   -Wall -Wpedantic -O2 -DNDEBUG  -L/path/to/cuda/lib64 -rdynamic CMakeFiles/vectorAdd.dir/examples/modified_cuda_samples/vectorAdd/vectorAdd_generated_vectorAdd.cu.o CMakeFiles/vectorAdd.dir/vectorAdd_intermediate_link.o  -o examples/bin/vectorAdd lib/libcuda-api-wrappers.a -Wl,-Bstatic -lcudart_static -Wl,-Bdynamic -lpthread -ldl -lrt -lnvToolsExt -Wl,-Bstatic -lcudadevrt -Wl,-Bdynamic
CMakeFiles/vectorAdd.dir/vectorAdd_intermediate_link.o: In function `__cudaRegisterLinkedBinary_25_cublas_compute_70_cpp1_ii_f0559976':
link.stub:(.text+0xe0): undefined reference to `__fatbinwrap_25_cublas_compute_70_cpp1_ii_f0559976'
CMakeFiles/vectorAdd.dir/vectorAdd_intermediate_link.o: In function `__cudaRegisterLinkedBinary_25_xerbla_compute_70_cpp1_ii_cd7f3ad3':
link.stub:(.text+0x190): undefined reference to `__fatbinwrap_25_xerbla_compute_70_cpp1_ii_cd7f3ad3'
CMakeFiles/vectorAdd.dir/vectorAdd_intermediate_link.o: In function `__cudaRegisterLinkedBinary_23_nrm2_compute_70_cpp1_ii_8edbce95':
link.stub:(.text+0x240): undefined reference to `__fatbinwrap_23_nrm2_compute_70_cpp1_ii_8edbce95'
... more udnefined reference errors here ...


我的问题:为什么会发生这种情况,我该如何规避/避免/解决它?

笔记:


我正在使用可分离的编译
我在CUDA 9.1和SM 5.2设备(无7.0)中遇到了这些特定错误。
CMakeLists.txthere
我显然在构建之前要清除CMakeCache.txt
我在GNU / Linux Mint 18.3和Fedora 26上都遇到了这种情况。在第一台机器上,已经完成了一些apt-get dist-upgrade的工作,现在GCC的版本是5.5.0,以防万一。在第二台计算机上-我确实没有发现任何变化;相同的编译器和CUDA版本。

最佳答案

部分答案/解决方法:

仅当涉及libcublas时,才会出现此问题。如果我从/path/to/cuda/lib64/libcublas_device.a阶段命令行中删除-dlink,则所有警告和错误都会消失(包括以后的阶段)。实际上,我的包装器库没有使用cublas,不确定CMake为什么要添加它。它不在$CUDA_LIBRARIES中。也可以看看:

Why does CMake force the use of libcublas with separable compilation?

关于c++ - 链接时突然收到maxrregcount警告和未定义的引用错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50581280/

10-11 23:08
查看更多