cuda编译错误 ptxas fatal : Unresolved extern function xxxx

编程入门 行业动态 更新时间:2024-10-14 14:19:16

cuda编译<a href=https://www.elefans.com/category/jswz/34/1771449.html style=错误 ptxas fatal : Unresolved extern function xxxx"/>

cuda编译错误 ptxas fatal : Unresolved extern function xxxx

出现这个问题。找到了原因是,在global函数中调用了__device__函数,但是这两个文件不在同一个src文件里面。



The issue is that you defined a __device__ function in separate compilation unit from __global__that calls it. You need to either explicitely enable relocatable device code mode by adding -dc flag or move your definition to the same unit.

From nvcc documentation:

--device-c|-dc Compile each .c/.cc/.cpp/.cxx/.cu input file into an object file that contains relocatable device code. It is equivalent to --relocatable-device-code=true --compile.

See Separate Compilation and Linking of CUDA C++ Device Code for more information.





因此解决的方式有2个。

第一是两个函数放到同一个cu文件中。

第二是在cu文件属性页面选项卡中 cuda c/c++->common->Generate Relocatable Device Code 选择-rdc=true。允许重定位device代码编译。或者在整个工程的cuda c/c++项中配置这个-rdc=true.




解决问题。


其他参考

/

1) View -> Property Pages
2) Configuration Properties -> CUDA C/C++ -> Common -> Generate Relocatable Device Code -> Yes (-rdc=true)
3) Configuration Properties -> CUDA C/C++ -> Code Generation -> compute_35,sm_35
4) Configuration Properties -> Linker -> Input -> Additional Dependencies -> cudadevrt.lib

更多推荐

cuda编译错误 ptxas fatal : Unresolved extern function xxxx

本文发布于:2023-06-24 01:38:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/857515.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   fatal   ptxas   cuda   function

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!