Initialization error when running under ASP.NET

The following code snippet:

float* d_priceGauss;

unsigned int mem_size = totGaussSequencePlus1 * totGaussSamples * sizeof(float);

cudaError err = cudaMalloc( (void**) &d_priceGauss, mem_size);

char errBuf[500];

if( cudaSuccess != err)

{                                               

    sprintf(errBuf, "Cuda error in file '%s' in line %i : %s.",

                __FILE__, __LINE__, cudaGetErrorString( err) );  

    return 100;

}

works OK when run under a .NET 2.0 console application (the CUDA code is compiled into an unmanaged Win32 DLL, called via interop). However…

When I call exactly the same DLL from an ASP.NET application (all else being equal), the call above returns cudaInitializationError. In other words, the only variable here is the host: in the successful case, a .NET 2.0 console application; in the failed case, an ASP.NET 2.0 web application. Needless to say, the one shown is the first CUDA call in the application.

Permission-wise, I made the web app run as the same user account under which I am logged on (admin user) and under which I run the successful console app.

Any other ideas of what the difference could be?

Thanks.

I answer my own question… this bizarre behavior seems to be Vista-specific, due to so-called “Session 0 isolation”. For more info see this Microsoft article, which states quite unambiguously that

Now, ASP.NET runs as a Windows service, and it has therefore no access to the video driver. To confirm this, I get the same negative result by running the CUDA code in a plain vanilla Windows service, whereas everything works as expected when running it under a console application or a Windows UI application.

Perhaps someone could put the final nail in the coffin by testing CUDA’s behavior under IIS in Windows XP? (Have no access to an XP box with a CUDA-supported card right now). Theoretically there it should work.