yalsaffar commited on
Commit
e1c3caf
·
1 Parent(s): add0ca0

Updated Dockerfile for Hugging Face Spaces deployment

Browse files
Files changed (2) hide show
  1. Dockerfile +6 -5
  2. models/nllb.py +2 -7
Dockerfile CHANGED
@@ -44,12 +44,13 @@ ENV PATH=${CUDA_HOME}/bin:${PATH}
44
  # Optionally set LD_LIBRARY_PATH for CUDA libraries
45
  ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
46
 
47
- # Create cache directory with appropriate permissions
48
- RUN mkdir -p /app/.cache/huggingface && chmod -R 777 /app/.cache/huggingface
 
49
 
50
- # Set environment variables for Hugging Face cache directory
51
- ENV HF_HOME=/app/.cache/huggingface
52
- ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
53
 
54
  # Copy the setup script and requirements file into the container
55
  COPY setup.sh requirements.txt /app/
 
44
  # Optionally set LD_LIBRARY_PATH for CUDA libraries
45
  ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
46
 
47
+ # Create cache directory
48
+ RUN mkdir -p /app/cache/huggingface
49
+ RUN chmod -R 777 /app/cache/huggingface
50
 
51
+ # Set environment variables for cache directory
52
+ ENV HF_HOME=/app/cache/huggingface
53
+ ENV TRANSFORMERS_CACHE=/app/cache/huggingface
54
 
55
  # Copy the setup script and requirements file into the container
56
  COPY setup.sh requirements.txt /app/
models/nllb.py CHANGED
@@ -21,13 +21,8 @@ def nllb():
21
  # Load the tokenizer and model
22
  # Set Hugging Face cache directory
23
  # Ensure the cache directory exists and has the correct permissions
24
- cache_dir = "/app/.cache/huggingface"
25
- if not os.path.exists(cache_dir):
26
- os.makedirs(cache_dir)
27
- os.chmod(cache_dir, 0o777)
28
-
29
- os.environ['HF_HOME'] = cache_dir
30
- os.environ['TRANSFORMERS_CACHE'] = cache_dir
31
 
32
  # Load models
33
  tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-1.3B")
 
21
  # Load the tokenizer and model
22
  # Set Hugging Face cache directory
23
  # Ensure the cache directory exists and has the correct permissions
24
+ os.environ['HF_HOME'] = '/app/cache/huggingface'
25
+ os.environ['TRANSFORMERS_CACHE'] = '/app/cache/huggingface'
 
 
 
 
 
26
 
27
  # Load models
28
  tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-1.3B")