Issue: User's deploying a model as Model API. The build process completes successfully, but when try to start the current version it failed with Permission denied error,
Jan 05 2023 14:21:02 -0500 workingdirectory: /mnt/e424653/SCAR-SOLO scriptpath: scrape.py endpointfunctionname: scrape ip-146-69-183-218.us-gov-west-1.compute.internal model-63b71a793ead9f6e56079451-6f8948c96d-f7ftl model-63b71a793ead9f6e56079451
Jan 05 2023 14:21:05 -0500 There was a problem when trying to write in your cache folder (/.cache/huggingface/hub). You should set the environment variable TRANSFORMERS_CACHE to a writable directory.
Jan 05 2023 14:21:05 -0500 PermissionError: [Errno 13] Permission denied: '/.cache'
Solution:
User's python code uses Transformers packages. Cache directory is set by default to "/.cache; however user can specific a different location in his code to solve this permission denied error.
Example for python:
import os
os.environ['TRANSFORMERS_CACHE'] = '/blabla/cache/'
Example for bash:
export TRANSFORMERS_CACHE=/blabla/cache/
The Transformers documentation describes how the default cache directory is determined:
Cache setup
Pretrained models are downloaded and locally cached at: ~/.cache/huggingface/transformers/. This is the default directory given by the shell environment variable TRANSFORMERS_CACHE. On Windows, the default directory is given by C:\Users\username.cache\huggingface\transformers. You can change the shell environment variables shown below - in order of priority - to specify a different cache directory:
- Shell environment variable (default): TRANSFORMERS_CACHE.
- Shell environment variable: HF_HOME + transformers/.
- Shell environment variable: XDG_CACHE_HOME + /huggingface/transformers.
What this piece of documentation doesn't explicitly mention is that HF_HOME defaults to $XDG_CACHE_HOME/huggingface and is used for other huggingface caches, e.g. the datasets cache, which is separate from the transformers cache. The value of XDG_CACHE_HOME is machine dependent, but usually it is $HOME/.cache (and HF defaults to this value if XDG_CACHE_HOME is not set) - thus the usual default $HOME/.cache/huggingface
So you probably will want to set the HF_HOME environment variable (and possibly set a symlink to catch cases where the environment variable is not set).
export HF_HOME=/path/to/cache/directory
Comments
0 comments
Please sign in to leave a comment.