Disable pytorch from reserving CUDA memory

I there a way to disable pytorch caching allocator from reserving cuda memory?

I assume you would like to disable the caching mechanism and force the allocator to use alloc/free for each (de-)allocation? If so, then you could use PYTORCH_NO_CUDA_MEMORY_CACHING=1. Note that this is a debugging env variable as you would see a large performance decrease.