How to cleanup PyTorch CPU cache

By using torch.cuda.empty_cache() we can clean the cache of GPU.

But, is there any way to clear the cache of CPU?

To do so, you can simply restart the runtime environment.

I want to clean CPU cache after every epochs during training

It looks it has nothing to do with pytorch, but python. You can take a look at Garbage collectors and how they work to clear up unused objects’ space.
A reference article: Python Garbage Collection: What It Is and How It Works – Stackify

There is no explicit Cache Allocator used by PyTorch for CPU RAM, unlike GPU.
For details, please discuss here in their official forum: