cudaDeviceReset() with CUDAFY

Dec 9, 2012 at 2:26 PM

Hi,

is there any way how to call cudaDeviceReset(), or is it called automatically at some point ?

Thanks for answer

Jan

Coordinator
Dec 10, 2012 at 6:39 AM

Hi Jan,

cudaDeviceReset is part of the run time API whereas CUDAfy is built on the driver API.  There is not direct equivalent.  Need to check what the side effects will be when calling this from CUDAfy.  Do you have a use case you can share?

Nick

Dec 10, 2012 at 7:35 AM

Hi,

thanks for answer,

I was just unable to profile my aplication. CUDA Visual Profiler just showed me a message that I probably forgot to call cudaDeviceReset()

Jan

May 7, 2013 at 11:10 PM
+1 for this. I've been unable to use the profiler for the same reason. Suggestions?
Coordinator
May 9, 2013 at 7:46 AM
Adding cudaDeviceReset() would not be difficult but this is actually from the runtime API and as far as I can see there is no equivalent in the driver API that CUDAfy uses. There are also two additional calls that would be useful: cudaProfilerStart and cudaProfilerStop.
What error message are you seeing with the profiler? With the latest Visual Profiler I am seeing a a No timeline message. Using an old version of the profiler there are no issues.
May 9, 2013 at 11:30 AM
Hi Nick, it seems profiler functions are available on the device api, but GASS didn't import them. Should be a simple matter adding them. Check it out:
http://docs.nvidia.com/cuda/cuda-driver-api/index.html#group__CUDA__PROFILER

Speaking of which, the functions "cuFuncSetCacheConfig"/ "cuCtxSetCacheConfig" and "cuFuncSetSharedMemConfig" / "cuCtxSetSharedMemConfig" would also be a welcome addition to cudafy, no? And event management, such as cuEventCreate, cuStreamWaitEvent etc, might also be useful for advanced scenarios.

As for device clean-up, you're right, i could find no analogue on the driver api to "cudaDeviceReset". I wonder what that method does internally, since ultimately it will have to call the driver api. I suspect it won't do more than memory clean-up, stream and ctx destruction (beside counter resets and stuff).

As for the visual profiler, I once had that particular error when I was doing bad things with device memory. I think you shouldn't need to call cudaDeviceReset. But I could be mistaken.
May 9, 2013 at 7:50 PM
It appears I can't actually paste an image here, but the error is:

Session Timeline Incomplete

Unable to read the entire session timeline. The displayed timeline may be empty or incomplete because the application aborted or failed to flush profile data before exiting. The application should call cudaDeviceReset() before exiting to ensure that all profile data is flushed.

@NickKopp what profiler version are you using that works?
Coordinator
May 9, 2013 at 9:01 PM
4.0.17
May 10, 2013 at 3:24 PM
Awesome. I downloaded the last v4.* toolkit from NVidia and the profiler does, in fact, work.

Thanks!