Below is a small program that tryes to initialize second GPU, allocates memory, frees it and then releases second GPU.
In this code cuCtxDestroy crashes. If I comment first malloc (on first GPU) or second malloc (on second GPU) all is Ok.
Where is mistake? Guide promise that I can mix runtime and driver api.
int main(int argc, char* argv[])
{
CUcontext ctxs[10];
cuSafeCall( cuInit(0) );
void *ptr;
size_t step;
cudaMallocPitch(&ptr, &step, 100, 100);
//cuSafeCall( cuCtxAttach(&ctxs[0], 0) );
//cuSafeCall( cuCtxDetach(ctxs[0]) );
CUdevice dev;
cuDeviceGet(&dev, 1);
cuCtxCreate(&ctxs[1], 0, dev);
void *ptr2;
size_t step2;
cudaMallocPitch(&ptr2, &step2, 100, 100);
cudaFree( ptr2 );
//crash
cuCtxDestroy(ctxs[1]);
cout << "unreacheble place in code" << endl;
}
Configuration:
-
GeForce 470
-
GeForce 9600
-
Toolikt 3.1 32-bit
-
Win7 64-bit
-
Compiled with “-gencode arch=compute_11,code=sm_11”