2016-10-24 73 views
0

我有一个我想在GPU上执行的ptx代码。我使用下面的代码是:cudaModuleLoadData失败,错误代码为201

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。我不知道这是什么错误代码的含义。有人能帮我找出错误吗?

回答

1

正如您在相关的documentation中所看到的,错误201是CUDA_ERROR_INVALID_CONTEXT,这意味着在尝试加载模块之前您没有正确设置上下文。

相关问题