Skip to content

Commit f2fdae2

Browse files
authored
Take TORCH_HOME env variable into account while setting the cache dir (#1741)
1 parent 70fc104 commit f2fdae2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

torchtext/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
from torchtext import _extension # noqa: F401
55

66
_TEXT_BUCKET = "https://download.pytorch.org/models/text/"
7-
_CACHE_DIR = os.path.expanduser("~/.cache/torch/text")
7+
8+
_TORCH_HOME = os.getenv("TORCH_HOME")
9+
if _TORCH_HOME is None:
10+
_TORCH_HOME = "~/.cache/torch" #default
11+
_CACHE_DIR = os.path.expanduser(os.path.join(_TORCH_HOME, "text"))
812

913
from . import data, datasets, experimental, functional, models, nn, transforms, utils, vocab
1014

0 commit comments

Comments
 (0)