ptxas fatal : Unresolved extern function xxxx

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

http://stackoverflow.com/questions/31006581/cuda-device-unresolved-extern-function


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.



http://stackoverflow.com/questions/17188527/cuda-external-class-linkage-and-unresolved-extern-function-in-ptxas-file


因此解决的方式有2个。

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

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




解决问题。


其他参考

https://devtalk.nvidia.com/default/topic/524436/how-to-deal-with-ptxas-fatal-error-unresolved-extern-function-39-cudagetparameterbuffer-39-/

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


——————————————————————

另附:http://www.cnblogs.com/djiankuo/p/5910502.html




  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值