vhr1007 commited on
Commit
733fb63
·
1 Parent(s): fa9bed8
Files changed (2) hide show
  1. Dockerfile +1 -1
  2. utils/embedding_utils.py +9 -8
Dockerfile CHANGED
@@ -5,7 +5,7 @@ FROM python:3.10.9
5
  WORKDIR /app
6
 
7
  # Set a writable directory for Hugging Face cache
8
- ENV TRANSFORMERS_CACHE=/app/huggingface_cache
9
 
10
  # Create the cache directory
11
  RUN mkdir -p /app/.cache/huggingface
 
5
  WORKDIR /app
6
 
7
  # Set a writable directory for Hugging Face cache
8
+ # ENV HF_HOME /app/.cache/huggingface
9
 
10
  # Create the cache directory
11
  RUN mkdir -p /app/.cache/huggingface
utils/embedding_utils.py CHANGED
@@ -17,21 +17,22 @@ import logging
17
  # Load environment variables from .env file
18
  #load_dotenv()
19
 
20
- os.environ["TRANSFORMERS_CACHE"] = "/app/huggingface_cache"
 
21
 
22
  # Ensure the cache directory exists
23
- cache_dir = os.environ["TRANSFORMERS_CACHE"]
24
  if not os.path.exists(cache_dir):
25
  os.makedirs(cache_dir)
26
-
27
  # Load Hugging Face token from environment variable
28
- # huggingface_token = os.getenv('HUGGINGFACE_HUB_TOKEN')
29
 
30
 
31
- # if huggingface_token:
32
- # login(token=huggingface_token, add_to_git_credential=True, write_permission=True)
33
- # else:
34
- # raise ValueError("Hugging Face token is not set. Please set the HUGGINGFACE_HUB_TOKEN environment variable.")
35
 
36
  # Load model and tokenizer with authentication
37
  model_name = 'nvidia/NV-Embed-v1'
 
17
  # Load environment variables from .env file
18
  #load_dotenv()
19
 
20
+ # Set the HF_HOME environment variable to a writable directory
21
+ os.environ["HF_HOME"] = "/tmp/huggingface_cache"
22
 
23
  # Ensure the cache directory exists
24
+ cache_dir = os.environ["HF_HOME"]
25
  if not os.path.exists(cache_dir):
26
  os.makedirs(cache_dir)
27
+
28
  # Load Hugging Face token from environment variable
29
+ huggingface_token = os.getenv('HUGGINGFACE_HUB_TOKEN')
30
 
31
 
32
+ if huggingface_token:
33
+ login(token=huggingface_token, add_to_git_credential=True, write_permission=True)
34
+ else:
35
+ raise ValueError("Hugging Face token is not set. Please set the HUGGINGFACE_HUB_TOKEN environment variable.")
36
 
37
  # Load model and tokenizer with authentication
38
  model_name = 'nvidia/NV-Embed-v1'