8
编译器
使用dtk-23.04编译CUDA代码链接报错
2024-10-10 13:23:02
127

操作系统版本:Red Hat 4.8.5-39

DTK 版本:DTK-23.04

驱动版本:rock-4.5.2-0-5.11.36-1.x86_64

DCU类型:Z100

异常描述:Makefile 编译包含 .cu 文件的程序时,链接时出现问题。输出:

Linking GPU codes

Warning: nvcc current only support gfx906 and gfx926 arch. All architecture parameters will be replaced by gfx906 arch.

/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../bin/ld: /tmp/__gpu__CUAPI_Asyn_FluidSolver-bde963.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC

/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../bin/ld: /tmp/__gpu__CUAPI_DiagnoseDevice-71fbb4.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC

/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../bin/ld: /tmp/__gpu__CUAPI_MemAllocate_Fluid-54bd42.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC

......

/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../bin/ld: /tmp/__gpu__CUSRC_Src_Deleptonization-914447.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC

/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../bin/ld: /tmp/__gpu__CUSRC_Src_User_Template-4fc3d0.o: relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC

/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../bin/ld: final link failed: Nonrepresentable section on output

clang-14: error: linker command failed with exit code 1 (use -v to see invocation)

Makefile在附件中。

全部评论(4)
只看楼主
C
changhl
2楼
您好,我这边用你的makefile文件make -n看了一下,mpicxx的编译命令中没有-fPIC参数,您可以试试在您提供的makefile的第40行加一下-fPIC参数试试呢。
2024/10/14
网
网友Uy6CNy
回复 @changhl
在第40行末尾加了,还是一样的报错
2024/10/14
C
changhl
回复 @changhl
-fPIC相关bug我这边复现已解决,主要原因为:编译cuda程序时没有-fPIC参数,可以通过make clean;make -n后查看详细的nvcc相关编译命令。您这边先试试,详细改动已私发给您:woshou:emoji
2024/10/14
C
changhl
1楼

1.您可以尝试一下修改Makefile文件哈,在已有的CXXFLAG后面加上-fPIC试试呢

2.您可以尝试更换一下dtk版本试一下

如果还不能解决,能否提供一下编译的程序案例,我们这边试一下
2024/10/11
没有更多内容了
--
楼主
Level.1
0 帖子
楼主热帖
暂无数据