Johns Paul Johns Paul - 1 month ago 10
C++ Question

cudaModuleLoadData fails with error code 201

I have a ptx code that I want to execute on the GPU. I am using the following code to this:

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;
}


The cuModuleLoadData function return an error code 201. I have no idea what this error code means. Could someone help me identify the error?

Answer

As you can see in the relevant documentation,

Error 201 is CUDA_ERROR_INVALID_CONTEXT which means you have not correctly setup up a context prior to trying to load a module.

Comments