我有一个要在 GPU 上执行的 ptx 代码。我为此使用以下代码:
CUmodule cudaModule;
//the variable that stores the error associated with cuda API calls.
CUresult cudaErrorVariable;
//variable representing any cuda kernel function.
CUfunction CUDAPipelineKernel;
//initializing cuda driver
cudaErrorVariable = cuInit(0);
//checking for error while loading ptx code in CUmodule.
if(cudaErrorVariable != CUDA_SUCCESS){
myLogger->error("Unable to initialize CUDA driver");
return 1;
}
//loading the ptx code into the module.
cudaErrorVariable = cuModuleLoadData(&cudaModule, PTXCode);
//checking for error while loading ptx code in CUmodule.
if(cudaErrorVariable != CUDA_SUCCESS){
cuGetErrorString(cudaErrorVariable, (const char **)&errorString);
myLogger->error("Unable load ptx file into the module : CUDA Error {}", cudaErrorVariable);
return 1;
}
cuModuleLoadData 函数返回一个错误代码 201。我不知道这个错误代码是什么意思。有人可以帮我找出错误吗?
最佳答案
这是 cuInit 的链接,如文档中所述,这是在任何 cuda 驱动程序 API 调用之前要调用的第一个也是最重要的函数。
为了完整起见,这里是上下文创建的链接:cuCtxCreate .
您也可以使用 Primary context , 受 cuda 示例目录中的 6_Advanced/ptxjit
示例启发,该示例使用 cudaMalloc
延迟初始化。
The primary context is unique per device and shared with the CUDA runtime API. These functions allow integration with other libraries using CUDA.
关于c++ - cudaModuleLoadData 失败,错误代码为 201,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40212911/