contexts vs portable memory allocation potential bug in cuda driver api

I have a very primitive code. i think it should work, but the second (portable memory) allocation fails.

It is caused by second context creation, if i remove it, everything works fine.


#include “cuda.h”

int main(int argc, char* argv)


void* a =0;

void* b =0;

CUcontext ctx1=0;

CUcontext ctx2=0;



cuCtxCreate(&ctx1, 0 , 0 );


// ***** second context creation *********

cuCtxCreate(&ctx2, 0 , 0 );





CUresult ra = cuMemHostAlloc( &a, 4, CU_MEMHOSTALLOC_PORTABLE );   //  <---Success

CUresult rb = cuMemHostAlloc( &b, 4, CU_MEMHOSTALLOC_PORTABLE ); // <-failed


return 0;


Environment info:

Win7 x64 RC1

Visual Studio 2008 VC++ compiler

CUDA toolkit 2.3 ( 3.0beta same behaviour)

Driver: 196.21

Hardware: 2 X GTX280


I think, that I use context management well, and I’m sure that I have more free memory than 4 bytes.

SOLVED! This may be a bug in that driver.
I moved back to 190.38, and problem disappeared.