Astariul
Astariul

Reputation: 2354

How to modify path where Torch Hub models are downloaded

When I download models through Torch Hub, models are automatically downloaded in /home/me/.cache/torch.

How can I modify this behavior ?

Upvotes: 24

Views: 25525

Answers (1)

Astariul
Astariul

Reputation: 2354

From official documentation, there is several ways to modify this path.
In priority order :

  1. Calling hub.set_dir(<PATH_TO_HUB_DIR>)

  2. $TORCH_HOME/hub, if environment variable TORCH_HOME is set.

  3. $XDG_CACHE_HOME/torch/hub, if environment variable XDG_CACHE_HOME is set.

  4. ~/.cache/torch/hub

So I just had to do :

export TORCH_HOME=/my/path/


Edit

TORCH_HUB appear to be deprecated, use TORCH_HOME instead

Upvotes: 34

Related Questions