pub struct GpuModule { /* private fields */ }Expand description
RAII handle to a loaded GPU module within a GPU session.
§Ownership model (Phase 48.16 SDK polish)
GpuModule is Clone but not Copy. When the last clone is
dropped it automatically calls gpu_session_module_unload for the
underlying CUDA module, unless you explicitly unloaded it first via
GpuSession::module_unload.
The intended pattern is symmetric with GpuMemHandle:
let m = sess.module_load(&ptx)?;
sess.launch(&m, "k", [1,1,1], [1,1,1], &args, &sizes)?;
// either explicitly unload:
sess.module_unload(m)?;
// ...or just let `m` go out of scope; Drop unloads it.Drop is best-effort: it silently swallows hostcall errors and never panics. If the lease has already expired, the daemon’s W3.5-validated lease-expiry teardown chain has already unloaded the module, so Drop suppresses the call entirely in that case.
Migration note: prior to the SDK polish wave this type was
Copy. Cloned handles share the same underlying CUmodule and the
same freed state; only the last clone to drop will issue the
module_unload.