链接时突然收到maxrregcount警告和未定义的引用错误
Suddenly getting maxrregcount warnings and undefined reference errors when linking
我维护 C+=-flavored CUDA API 包装器库。库的当前提交是相对经过良好测试的,有一些示例程序和相当多的用户。但是,最近某个时候(不能确切地说出何时(,并且没有提交任何新内容,我现在在我的示例程序的"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 ...
但眨眼的脸确实总结了。这已经很奇怪了,因为我没有明确使用任何测试版功能。
/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.txt
就在这里。- 我显然在建造之前清理
CMakeCache.txt
。 - 这在GNU/Linux Mint 18.3和Fedora 26上都发生在我身上。在第一台机器上,已经完成了一些apt-get dist-upgrade,现在GCC已经升级到5.5.0版本,以防万一。在第二台机器上 - 我知道确实没有变化;相同的编译器和 CUDA 版本。
部分答案/解决方法:
此问题似乎仅在涉及libcublas时才发生。如果我从-dlink
阶段命令行中删除/path/to/cuda/lib64/libcublas_device.a
,所有警告和错误都会消失(包括后期阶段(。事实上,我的包装库忘记了 cublas,不知道为什么 CMake 要添加它;它不在$CUDA_LIBRARIES
.另请参阅:
为什么 CMake 强制使用具有可分离编译的 libcublas?
相关文章:
- 对C宏的未定义引用,但在定义它时会出现重新定义错误
- 编译时的 CImg 库返回对"__imp_SetDIBitsToDevice"的未定义引用
- 对Py_Initialize()的未定义引用
- 使用mysql c++连接器的未定义引用
- 对 Scalar ::Scalar() 的未定义引用
- 对复制 CTOR 和 CTOR 的未定义引用
- 对显式实例化的模板函数的未定义引用
- TensorRT (C++ API) 对"createNvOnnxParser_INTERNAL"的未定义引用
- 2个模板化类的非模板友元函数未定义引用错误
- 编译 libfluid 样本控制器时对"event_base_del_virtual"的未定义引用
- 获取对function_name的未定义引用
- 对 'std::thread::_M_start_thread CMake 的未定义引用进行基准测试
- 对结构方法的未定义引用
- 使用内联函数 c++ 的未定义引用
- 对 CMake 中'cudaRegisterLinkedBinary'链接错误的未定义引用?
- 对 DLOPEN 的未定义引用
- QT C++中对全局变量的未定义引用
- 快速数学导致对"__pow_finite"的未定义引用
- 对 boost::system::d etail::system_category_instance 的未定义引用,从
- OpenCV 3.4.3 中对 'cv::String::d eallocate()' 错误的未定义引用