Fix: CUDA module memory leak since using primary context

Previously the CUDA context was always destroyed and the module along
with it. Now that this no longer happens, the missing module free became
a memory leak.

Also fix the same issue for HIP, though this is destroying the context
so it's not a problem yet.

Fix part of #119035

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
This commit is contained in:
Attila Afra
2024-03-09 23:42:45 +02:00
committed by Brecht Van Lommel
parent e480b6a50c
commit 60e8b56bcd
2 changed files with 6 additions and 2 deletions

View File

@@ -135,7 +135,9 @@ CUDADevice::CUDADevice(const DeviceInfo &info, Stats &stats, Profiler &profiler)
CUDADevice::~CUDADevice()
{
texture_info.free();
if (cuModule) {
cuda_assert(cuModuleUnload(cuModule));
}
cuda_assert(cuDevicePrimaryCtxRelease(cuDevice));
}

View File

@@ -126,7 +126,9 @@ HIPDevice::HIPDevice(const DeviceInfo &info, Stats &stats, Profiler &profiler)
HIPDevice::~HIPDevice()
{
texture_info.free();
if (hipModule) {
hip_assert(hipModuleUnload(hipModule));
}
hip_assert(hipCtxDestroy(hipContext));
}