c++ - cudaModuleLoadData 失败,错误代码为 201

标签 c++ cuda gpu

我有一个要在 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/

相关文章:

C++ 2011:std::thread:并行化循环的简单示例?

cuda - 关于经纱投票功能

ubuntu - 使用 Ubuntu 在 AWS GPU 实例上运行 OpenGL

cuda - 硬件 warp 调度程序如何形成和处理 warp?

OpenGL,测量 GPU 上的渲染时间

c++ - 强制只输入字母

c++ - 任意精度无符号整数仅支持后递增运算符

c++ - OpenMP 递归任务

c++ - CUDA 调度问题或内核启动中的错误?

c - 如何在 CUDA 中将包含数组的结构传递给内核?