|
|
|
|
|
by eden_h
2155 days ago
|
|
Ran into this issue with a crate that uses CUDA in Rust - how do you hang onto the pointer to CUBLAS/CUDNN so that all CUDA functions use the same pointers and also it goes out of scope at the end of execution. The big problem is the second part - lazy static doesn't allow you to run destructors, and this is one of the few times you really need a custom destructor to tell Rust to kill the CUBLAS/CUDNN pointers at appropriate times. Ended up connecting it to a struct so that the destructor could be tied to the object rather than anything else, but lazystatic's (lack of) story around destructors definitely created a bunch of problems that weren't apparent until we started finding memory leaks. |
|