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

> ~/.cache/torch holds pretrained weights and Hub repos PyTorch downloads. Deleting it is safe; files download again the next time your code loads them.

- Updated: 2026-10-10
- URL: https://fresh.ist/caches/torch-cache/

**TL;DR:** Yes. ~/.cache/torch is where PyTorch Hub saves downloaded repos and pretrained weights, for example when torchvision loads a model with weights. Your scripts, notebooks and trained models aren't stored there. PyTorch never cleans this folder itself, so removing old checkpoints is the only way to reclaim the space. Anything you delete is downloaded again on next use.

## Facts from the Freshist app

- Category in Clean: PyTorch Cache — "PyTorch model/dataset cache — re-downloaded when next needed."
- Location: `~/.cache/torch`
- Risk level: Medium risk — Safe 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
- What Freshist does: Moves the selected items to the Trash, so you can undo. Nothing is deleted outright.

## 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:

| Folder | Contents |
| --- | --- |
| `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 subfolders | Files 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

```bash
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](/caches/huggingface/), and the [developer caches overview](/blog/developer-caches-mac/) lists the other places Python tooling keeps downloads.

## Sources

- [PyTorch docs: torch.hub (where downloaded models are saved, caching logic)](https://docs.pytorch.org/docs/stable/hub.html)
- [torchvision docs: Models and pre-trained weights](https://docs.pytorch.org/vision/stable/models.html)

## 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.

---

Canonical page: https://fresh.ist/caches/torch-cache/
Official site: https://fresh.ist/ (fresh.ist only)
Generated: 2026-10-10
