cudaModuleLoadData 失败,错误代码为 201
cudaModuleLoadData fails with error code 201
我有一个要在 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 函数return 错误代码 201。我不知道这个错误代码是什么意思。谁能帮我找出错误?
如您在相关 documentation 中所见,错误 201 是 CUDA_ERROR_INVALID_CONTEXT
,这意味着您在尝试加载模块之前没有正确设置上下文。
这是 link 到 cuInit,这是在任何 cuda 驱动程序 API 调用之前要调用的第一个也是最重要的函数,如文档中所述。
为了完整起见,这里是 link 上下文创建: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.
我有一个要在 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 函数return 错误代码 201。我不知道这个错误代码是什么意思。谁能帮我找出错误?
如您在相关 documentation 中所见,错误 201 是 CUDA_ERROR_INVALID_CONTEXT
,这意味着您在尝试加载模块之前没有正确设置上下文。
这是 link 到 cuInit,这是在任何 cuda 驱动程序 API 调用之前要调用的第一个也是最重要的函数,如文档中所述。
为了完整起见,这里是 link 上下文创建: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.