Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify path where Torch Hub models are downloaded

Tags:

path

pytorch

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

How can I modify this behavior ?

like image 817
Astariul Avatar asked Dec 02 '19 07:12

Astariul


1 Answers

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

  1. Calling hub.set_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_HUB=/my/path/


Edit

TORCH_HUB appear to be deprecated, use TORCH_HOME instead

like image 67
Astariul Avatar answered Oct 02 '22 14:10

Astariul