cuCtxCreate因CUDA_ERROR_INVALID_DEVICE而失败

时间:2012-04-24 00:27:26

标签: cuda

通过cuCtxCreate创建cuda上下文时,我收到CUDA_ERROR_INVALID_DEVICE错误。

我的代码正在创建一个上下文并从中获取设备并创建一个新的上下文。

知道为什么我不能创建另一个上下文吗?

#include<cuda.h>
#include<assert.h>

int main(){
        cuInit(0);
        CUcontext ctx;
        CUdevice device;

        CUdevice dev2;
        CUcontext c2;

        assert(cuDeviceGet(&device,0) == 0 );
        assert(cuCtxCreate(&ctx, 0, device) == 0);
        assert(cuCtxGetDevice(&dev2) == 0);
        assert(cuCtxCreate(&c2,0,dev2) == 0);
        return 0;
}

1 个答案:

答案 0 :(得分:3)

问题是用户让设备处于独占模式,禁止在单个设备上创建两个上下文。