-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
made torch home for storing checkpoints project-wide available
- Loading branch information
Showing
3 changed files
with
30 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import os | ||
|
||
ENV_TORCH_HOME = "TORCH_HOME" | ||
ENV_XDG_CACHE_HOME = "XDG_CACHE_HOME" | ||
DEFAULT_CACHE_DIR = "~/.cache" | ||
|
||
|
||
def get_torch_home(): | ||
""" | ||
Gets the torch home folder used as a cache directory for model checkpoints. | ||
""" | ||
torch_home = os.path.expanduser( | ||
os.getenv( | ||
ENV_TORCH_HOME, | ||
os.path.join( | ||
os.getenv( | ||
ENV_XDG_CACHE_HOME, DEFAULT_CACHE_DIR | ||
), | ||
"torch", | ||
), | ||
) | ||
) | ||
return torch_home |