首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cuFFT静态链接失败

cuFFT静态链接失败
EN

Stack Overflow用户
提问于 2020-08-06 17:29:38
回答 1查看 594关注 0票数 0

我试图静态地链接cuFFT。

代码语言:javascript
复制
nvcc -ccbin g++ -dc -O3 -arch=sm_35  -c fftStat.cu fftStat.o;
nvcc -ccbin g++ -dlink -arch=sm_35 fftStat.o -o link.o;
g++ main.cc link.o fftStat.o -lcudart -lcudadevrt -lcufft_static   -lculibos -ldl -pthread -lrt -L/usr/local/cuda-10.2/lib64 -o run

它给了我以下错误(没有显示所有的错误)

代码语言:javascript
复制
/usr/local/cuda-10.2/lib64/libcufft_static.a(fft_dimension_class_multi.o): In function `__sti____cudaRegisterAll()':
fft_dimension_class_multi.compute_75.cudafe1.cpp:(.text+0xdad): undefined reference to `__cudaRegisterLinkedBinary_44_fft_dimension_class_multi_compute_75_cpp1_ii_466e44ab'
/usr/local/cuda-10.2/lib64/libcufft_static.a(fft_dimension_class_multi.o): In function `global constructors keyed to BaseListMulti::radices':
fft_dimension_class_multi.compute_75.cudafe1.cpp:(.text+0x1c8d): undefined reference to 
float_64bit_regular_RT_SM50_plus.compute_75.cudafe1.cpp:(.text+0x3d): undefined reference to `__cudaRegisterLinkedBinary_51_float_64bit_regular_RT_SM50_plus_compute_75_cpp1_ii_66731515'
/usr/local/cuda-10.2/lib64/libcufft_static.a(float_64bit_regular_RT_SM50_plus.o): In function `global constructors keyed to compile_unitsforce_compile_float_width64_t_regular_fft_kernels__SM50_unbounded()':
float_64bit_regular_RT_SM50_plus.compute_75.cudafe1.cpp:(.text+0x29d): undefined reference to `__cudaRegisterLinkedBinary_51_float_64bit_regular_RT_SM50_plus_compute_75_cpp1_ii_66731515'
/usr/local/cuda-10.2/lib64/libcufft_static.a(float_64bit_regular_RT_SM60_plus.o): In function `__sti____cudaRegisterAll()':
float_64bit_regular_RT_SM60_plus.compute_75.cudafe1.cpp:(.text+0x3d): undefined reference to `__cudaRegisterLinkedBinary_51_float_64bit_regular_RT_SM60_plus_compute_75_cpp1_ii_dbb979db'
/usr/local/cuda-10.2/lib64/libcufft_static.a(float_64bit_regular_RT_SM60_plus.o): In function `global constructors keyed to compile_unitsforce_compile_float_width64_t_regular_fft_kernels__SM60_unbounded()':
float_64bit_regular_RT_SM60_plus.compute_75.cudafe1.cpp:(.text+0x18d): undefined reference to `__cudaRegisterLinkedBinary_51_float_64bit_regular_RT_SM60_plus_compute_75_cpp1_ii_dbb979db'
/usr/local/cuda-10.2/lib64/libcufft_static.a(half_32bit_regular_RT_SM53_plus.o): In function `__sti____cudaRegisterAll()':
half_32bit_regular_RT_SM53_plus.compute_75.cudafe1.cpp:(.text+0x3d): undefined reference to `__cudaRegisterLinkedBinary_50_half_32bit_regular_RT_SM53_plus_compute_75_cpp1_ii_96a57339'
/usr/local/cuda-10.2/lib64/libcufft_static.a(half_32bit_regular_RT_SM53_plus.o): In function `global constructors keyed to compile_unitsforce_compile_half_width32_t_regular_fft_kernels__SM53_unbounded()':
half_32bit_regular_RT_SM53_plus.compute_75.cudafe1.cpp:(.text+0x1b0d): undefined reference to `__cudaRegisterLinkedBinary_50_half_32bit_regular_RT_SM53_plus_compute_75_cpp1_ii_96a57339'
/usr/local/cuda-10.2/lib64/libcufft_static.a(half_32bit_vector_RT_SM53_plus.o): In function `__sti____cudaRegisterAll()':
half_32bit_vector_RT_SM53_plus.compute_75.cudafe1.cpp:(.text+0x3d): undefined reference to 
dpRadix0343C_cb.compute_75.cudafe1.cpp:(.text+0xa54): undefined reference to `__cudaRegisterLinkedBinary_34_dpRadix0343C_cb_compute_75_cpp1_ii_b592a056'
collect2: error: ld returned 1 exit status

动态链接工程:

代码语言:javascript
复制
g++ main.cc link.o fftStat.o -lcudart -lcudadevrt -lcufft -L/usr/local/cuda-10.2/lib64 -o run

我遵循了这个指南https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#code-changes-for-separate-compilation和这个向导https://docs.nvidia.com/cuda/cufft/index.html#static-library,但是显然缺少一些东西。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-06 18:10:29

有些事情,你想要完成的最后环节,需要完成在设备链接(你的第二步)。以下几点似乎适用于我:

代码语言:javascript
复制
$ cat fftStat.cu
#include <cufft.h>

void test(){

  cufftHandle h;
  cufftCreate(&h);
}

$ cat main.cpp
void test();

int main(){

  test();
}

$ nvcc -ccbin g++ -dc -O3 -arch=sm_35  -c fftStat.cu fftStat.o
$ nvcc -ccbin g++ -dlink -arch=sm_35 fftStat.o -o link.o -lcufft_static -lcudadevrt
$ g++ main.cpp link.o fftStat.o -L/usr/local/cuda-10.2/lib64   -lcufft_static -lcudart -lcudadevrt -lculibos -ldl -pthread -lrt  -o run

请注意,我还重新安排了一些链接顺序,以说明链接依赖关系。这可能重要,也可能不重要,取决于您的确切版本的g++。这里的一些需求(例如,设备链接步骤中的-lcudadevrt )可能是实际代码的一个函数,但您还没有显示出来。对于上面的代码,该项实际上并不是必需的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63288870

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档