-
Notifications
You must be signed in to change notification settings - Fork 59
Description
Is your feature request related to a problem? Please describe.
As we discovered in #145 (comment), when user deletes the pyfunc handle to launch the kernel, we should deem that there's no alternative to access the underlying module and they should be unloaded.
Describe the solution you'd like
It is suggested that there should be a finalizer on the _Kernel object. There is a 1:1 mapping from the _Kernel object to the underlying module. When the _Kernel object is finalized, it should remove the cumodule from the context.
Implementation detail
CUDADispatcher has many to one mapping (signature to module) to cumodules. When a user executes del kernel, it's the dispatcher class that's dereferenced. The dispatcher holds strong references to the _Kernel class in .overloads dict. So deleting the kernel handle actually triggers finalizing all overloads of the cufunction/cumodule corresponding to the dispatcher.