I’m using a dynamic language (Clojure) to create CUDA contexts in a interactive development way using JCuda. Often I will call an initializer that includes the call to jcuda.driver.JCudaDriver/cuInit. Is it safe to call cuInit multiple times? In addition, is there something like a destroy method for cuInit? I ask since its possible for an error code CUDA_ERROR_DEINITIALIZED to be returned.
I’m using a dynamic language (Clojure) to create CUDA contexts in a interactive development
Share
To answer the question, yes it is probably safe to call
cuInitmultiple times. I haven’t noticed any side effects from doing so.Note, however, that
cuInitonly triggers one-time initialisation processes inside the API. It doesn’t do anything with devices, or contexts and it definitely can’t return CUDA_ERROR_DEINITIALIZED. Doing the steps you would do after callingcuInitin an application (ie. creating a context) would have real implications – doing so creates a new context each time you call it and resource exhaustion will occur if contexts are not actively destroyed. There is no equivalent deinitialisation call for the API. I guess the intention is that once intialised, the runtime API is expected to stay in that state until an application terminates.