CudaDeviceReset v. cudaFree

There are various questions regarding the proper use of cudaDeviceReset() , but I could not find the answer to the following question.

The cudaDeviceReset() document says that it is explicitly destroys and cleans up all resources associated with the current device in the current process .

Suppose I have a program with many arrays, all allocated using cudaMalloc . Can I use cudaDeviceReset instead of many cudaFree at the end of my program to quickly free all memory on the device? Are there any flaws in this?

+4
source share
1 answer

You can call cudaDeviceReset() at the end of your application if you choose. In fact, it is recommended for the proper use of the visual profiler.

If you actually finished working with the GPU and are ready to exit the application, there should be no flaws when choosing cudaDeviceReset() if you choose. Please note: it is likely that none of these methods ( cudaDeviceReset and many cudaFree ) is really necessary for this scenario, since the application exit also frees up resources (due to the destruction of the cuda context when the application exits). But pay attention to the above statement about using the profiler.

+4
source

Source: https://habr.com/ru/post/1495252/


All Articles