I have following code in my program that works with pure driver API,
cuInit(0)
and Nvidia Visual Profiler 8.0 is not showing it on timeline graph.
Can I call it once in a while, or as frequently as pc wake-ups or should it be called only maximum once per process(which would need a singleton-like or some globally synchronized initializer wrapper for the application)?
Should I expect a trivial time loss per call always?
Does cuda driver API has an internal counter for it so that if somehow driver API unloads, it automatically re-loads it so I don't have to run it again later?
What if this C++ is a DLL and will be called from C#, Java, Phyton? Can other third-party libraries initialize it before my application? I know GPU does context switching between processes(is driver API independent per process?) but does this initialization command hinder others' work by accident(for example, in a cloud computer where N other users run CUDA too)?
cuInit()
should be called once per application, before any other cuda driver API calls are used .
I think the fact that it does not show up in the timeline is expected behavior.
There will be some time cost associated with cuInit()
. I wouldn't call it "trivial". It will vary based on a variety of system configuration parameters.
There is no concept of the driver API "unloading".
If you use any driver API calls in a library, this call must precede them as well, in library code.
I think you might be getting this confused with a CUDA context . cuInit()
does not create a context (ignoring the primary context). If you have a context created, it is possible to pass that context to other routines, even if they are in a dynamically linked library.
This call has no bearing on CUDA running in another process.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.