Cache directories¶
PyTorch and the libraries it uses like to save compiled code, downloaded models, or downloaded datasets to cache directories. By default, most of these point to your home directory, quickly consuming the limited available space.
Ideally, you can soft-link these cache directories to a project's SCRATCH directory, or set the corresponding environment variables in your scripts. As a general recommendation, soft-linking the entire ~/.cache directory to SCRATCH is a good idea because many programs, including pip, use it. This will also handle most of the cache directories mentioned here.
A detailed guide on soft-linking directories can be found in the jsc_basics guide.
Here are some of the variables concerning various libraries and their default values.
- PyTorch kernels:
PYTORCH_KERNEL_CACHE_PATH="$HOME"/.cache/torch/kernels - PyTorch compiler:
TORCHINDUCTOR_CACHE_DIR="$TMPDIR"/torchinductor_"$USER" - PyTorch Hub:
TORCH_HOME="$HOME"/.cache/torch/hub - PyTorch extensions:
TORCH_EXTENSIONS_DIR="$HOME"/.cache/torch_extensions - Triton (PyTorch dependency):
TRITON_HOME="$HOME"(.tritondirectory will be created under this location) (older versions have to useTRITON_CACHE_DIR="$HOME"/.triton/cache) - Triton cache (PyTorch dependency):
TRITON_CACHE_DIR="$TRITON_HOME"/.triton/cache(if not set, PyTorch will set this to"$TORCHINDUCTOR_CACHE_DIR"/triton/<device-index>") (older versions haveTRITON_CACHE_DIR="$HOME"/.triton/cacheas default)<!--TRITON_CACHE_DIR` mention can be removed on 2025-06-26, a year after its official documentation → - HuggingFace:
HF_HOME="$HOME"/.cache/huggingface