PyTorch Cache on Mac: Is ~/.cache/torch Safe to Delete?

Medium riskAI & machine learningUpdated

Facts from the app
Location
  • ~/.cache/torch
Risk level
Medium riskSafe to remove, but the tool that owns it re-downloads or rebuilds it on next use, which costs time and bandwidth. Listed, never pre-selected.
Selected by default
No — you choose whether to include it
What Freshist does
Moves the selected items to the Trash, so you can undo. Nothing is deleted outright.
In the app
Clean → PyTorch Cache — “PyTorch model/dataset cache — re-downloaded when next needed.”

From Freshist's own cleaning rules — the same catalog the app uses.

What PyTorch stores here

PyTorch Hub decides its download directory in a fixed order, according to the PyTorch docs:

  1. A path set in code with torch.hub.set_dir().
  2. $TORCH_HOME/hub, if TORCH_HOME is set.
  3. $XDG_CACHE_HOME/torch/hub, if XDG_CACHE_HOME is set.
  4. ~/.cache/torch/hub otherwise.

Without any of those set, the default on a Mac is ~/.cache/torch. Inside you'll usually find:

FolderContents
hub/<owner>_<repo>_<branch>Source code of GitHub repos loaded with torch.hub.load
hub/checkpoints/Pretrained weight files (.pth) fetched by load_state_dict_from_url, which torchvision and others use
Other subfoldersFiles some third-party libraries place under the same root

PyTorch never cleans it up

The "Caching logic" section of the PyTorch docs states: "By default, we don't clean up files after loading it." Each new architecture or weights version adds a file, and vision or speech checkpoints often weigh hundreds of megabytes to a few gigabytes. Hub repos for every project you tried stay as well.

What happens after you delete it

The next torch.hub.load or weights=... call downloads the files again and verifies them. That can be slow on large checkpoints, and it fails in environments without internet access. Training code, datasets you keep elsewhere, and your own saved models aren't affected. One nuance: torch.hub.load runs code from the downloaded repo, so a fresh download also fetches that repo's current code. That only matters if you relied on an older snapshot of an unpinned branch.

Find out what is cached

du -sh ~/.cache/torch
du -sh ~/.cache/torch/hub/* ~/.cache/torch/hub/checkpoints/* 2>/dev/null | sort -h
python3 -c "import torch; print(torch.hub.get_dir())"

The last line prints the hub directory PyTorch will really use, which is useful if TORCH_HOME is set in your shell or a notebook kernel.

Clearing it by hand

PyTorch has no cache-clean command, so manual removal is the method:

  1. Stop running notebooks and training jobs.
  2. In Finder, choose Go → Go to Folder… and enter ~/.cache/torch.
  3. Move individual files in hub/checkpoints or repo folders in hub that you no longer need to the Trash, or remove the whole torch folder.

Deleting a single checkpoint is often enough. File names include a hash fragment (for example resnet50-<hash>.pth), so different weight versions of one model sit side by side, and only the one your code currently requests is needed.

On machines where you want downloads in one known place, setting TORCH_HOME to a dedicated folder makes the cache easier to find and clear later.

Which checkpoints to keep

Checkpoints your current projects load on every run are worth keeping, more so if you sometimes work offline. Weights from finished experiments can go. Model files from the Transformers ecosystem are in the Hugging Face cache, and the developer caches overview lists the other places Python tooling keeps downloads.

Sources

Frequently asked questions

Will deleting ~/.cache/torch remove models I trained?

Not unless you saved them there yourself. torch.save writes wherever you tell it to. This folder only holds what PyTorch Hub and libraries built on it downloaded for you.

Why do I have a ~/.cache/torch folder if I don't use PyTorch Hub?

Libraries such as torchvision, timm or older sentence-transformers versions download pretrained weights through PyTorch's hub helpers, so the folder appears as soon as one of them fetches a model.

How do I move the PyTorch cache to another disk?

Set the TORCH_HOME environment variable before Python starts. PyTorch then uses $TORCH_HOME/hub instead of ~/.cache/torch/hub.

Keep reading