我正在尝试使用 PyCUDA(版本 2011,2,2)在 Tesla C2075(CUDA 5.0,V0.2.1221)上的 Python 2.7.3 中从 CUDA 内核内的正态分布创建一个随机数。但是,我在尝试简单地包含 curand_kernel.h header 时遇到了问题。我创建了最简单的测试用例(如下所示),但在编译时收到错误。
/usr/local/cuda/bin/../include/curand_kernel.h(568): error: this declaration may not have extern "C" linkage
尽管进行了四处搜索,但遗憾的是我仍然不完全理解问题所在,这使得解决它变得困难。任何帮助将不胜感激。
import pycuda.driver as drv
import pycuda.compiler
import pycuda.autoinit
import pycuda.gpuarray as gpuarray
import pycuda.cumath as cumath
from pycuda.compiler import SourceModule
gpu_test_source = SourceModule("""
#include <curand_kernel.h>
__global__ void test_kernel()
{
return;
}
""")
最佳答案
您尝试过以下操作吗?:
gpu_test_source = SourceModule("""
#include <curand_kernel.h>
extern "C"{
__global__ void test_kernel()
{
return;
}
}
""", no_extern_c=True)
关于c - PyCUDA 无法包含 <curand_kernel.h> - 错误 : no extern "C" linkage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20319258/