Menu

1 / 2

Tracing torch.cuda.empty_cache() on an RTX 4090 - Where Do the 53 MB Go?

DEV Community: pytorch·Ingero Team·5 months ago
#iPThd87N
#dev#empty_cache#pytorch#cuda#memory
Reading 0:00
15s threshold

TL;DR

After del tensor; torch.cuda.empty_cache() , PyTorch's caching allocator still holds 53.7 MB that it won't release. We traced the CUDA Runtime and Driver APIs with eBPF uprobes to see exactly what happens at the kernel level during the free path. The trace showed cudaFree calls hitting p99 = 1.9ms (4.6x their median) because the process keeps getting descheduled mid-free. The allocator isn't broken - the OS is interrupting it.

The Issue

pytorch/pytorch#173382 - a user calls torch.cuda.empty_cache() after deleting tensors, but GPU memory stays allocated. The caching allocator's empty_cache() only releases blocks it has marked as free, but the user sees a persistent gap between "allocated" and "reserved" memory.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.