[英]cuFFT static linking failed
我試圖靜態鏈接 cuFFT。
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
它給了我以下錯誤(未顯示所有錯誤)
/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
動態鏈接工作:
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但顯然缺少一些東西。
您嘗試在最終鏈接中完成的某些事情需要在設備鏈接中完成(您的第二步)。 以下似乎對我有用:
$ 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
)可能是您未顯示的實際代碼的 function。 對於上面的代碼,該項目實際上不是必需的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.