Skip to content

Commit 1a2ee9a

Browse files
authored
Leak NVDECCache to avoid calling into CUDA during static destruction (#1441)
1 parent c162451 commit 1a2ee9a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/torchcodec/_core/NVDECCache.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ extern "C" {
2121
namespace facebook::torchcodec {
2222

2323
NVDECCache* NVDECCache::getCacheInstances() {
24-
static NVDECCache cacheInstances[MAX_CUDA_GPUS];
24+
// Intentionally leaked to avoid calling into CUDA/NVCUVID during static
25+
// destruction, when the CUDA runtime may already be torn down.
26+
static NVDECCache* cacheInstances = new NVDECCache[MAX_CUDA_GPUS];
2527
return cacheInstances;
2628
}
2729

0 commit comments

Comments
 (0)