【发布时间】:2016-02-13 16:12:59
【问题描述】:
对于带有 Titan GPU (compute_35,sm_35) 的计算机,我使用 CMakeLists.txt 中的这一行编译了一些代码:
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_35,code=sm_35)
代码可以编译并且运行良好。
我想检查一下这段代码会给使用 GTS 450 (compute_20,sm_21) 的朋友带来哪些编译问题。所以,我将上面的行改为:
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_20,code=sm_21)
代码在我的计算机上使用 Titan 编译时没有任何错误。但是当我运行它(再次在我的 Titan 计算机上)时,它在 thrust::copy 调用后失败,并出现以下错误:
$ ./foobar
terminate called after throwing an instance of 'thrust::system::system_error'
what(): invalid device function
"foobar" terminated by signal SIGABRT (Abort)
Google 称上述错误是由于 GPU 架构不匹配造成的。
最奇怪的是,使用上面的行 (arch=compute_20,code=sm_21),代码在我朋友的 GTS 450 计算机上编译并运行没有错误!除了GPU,她的Ubuntu 12.04、gcc和CUDA SDK 5.5版本和我一样。
这是导致此错误的真正原因吗?为什么 Titan 不能运行 compute_20 代码? CUDA GPU 不应该向后兼容 PTX 或 SASS 代码吗?即使不是,为什么驱动JIT不能将compute_20 PTX编译成sm_35的SASS?
【问题讨论】: