Properly move cache when it is not in default path (#18563)

This commit is contained in:
Sylvain Gugger 2022-08-10 15:46:03 -04:00 committed by GitHub
parent 6936e7c487
commit 50949fab74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -1070,7 +1070,11 @@ if cache_version < 1:
"`transformers.utils.move_cache()`."
)
try:
move_cache()
if TRANSFORMERS_CACHE != default_cache_path:
# Users set some env variable to customize cache storage
move_cache(TRANSFORMERS_CACHE, TRANSFORMERS_CACHE)
else:
move_cache()
except Exception as e:
trace = "\n".join(traceback.format_tb(e.__traceback__))
logger.error(