Spaces:
Sleeping
Sleeping
SaiMupparaju
commited on
Commit
·
a1b8a33
1
Parent(s):
f7aa3bd
Fix NumPy version conflict and cache directory permissions
Browse files- Dockerfile +3 -4
- app.py +7 -7
- requirements.txt +1 -1
Dockerfile
CHANGED
|
@@ -3,12 +3,11 @@ FROM python:3.9
|
|
| 3 |
WORKDIR /code
|
| 4 |
|
| 5 |
# Create cache directories with appropriate permissions
|
| 6 |
-
RUN mkdir -p /
|
| 7 |
-
chmod 777 /tmp/transformers_cache /tmp/hf_home
|
| 8 |
|
| 9 |
# Set environment variables for the cache
|
| 10 |
-
ENV TRANSFORMERS_CACHE=/
|
| 11 |
-
ENV HF_HOME=/
|
| 12 |
|
| 13 |
COPY ./requirements.txt /code/requirements.txt
|
| 14 |
|
|
|
|
| 3 |
WORKDIR /code
|
| 4 |
|
| 5 |
# Create cache directories with appropriate permissions
|
| 6 |
+
RUN mkdir -p /code/model_cache /code/hf_home
|
|
|
|
| 7 |
|
| 8 |
# Set environment variables for the cache
|
| 9 |
+
ENV TRANSFORMERS_CACHE=/code/model_cache
|
| 10 |
+
ENV HF_HOME=/code/hf_home
|
| 11 |
|
| 12 |
COPY ./requirements.txt /code/requirements.txt
|
| 13 |
|
app.py
CHANGED
|
@@ -9,16 +9,16 @@ import json
|
|
| 9 |
app = Flask(__name__)
|
| 10 |
|
| 11 |
# Set cache directory to a location where we have write permissions
|
| 12 |
-
os.
|
| 13 |
-
os.
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Make sure the directories exist with proper permissions
|
| 16 |
try:
|
| 17 |
-
os.makedirs(
|
| 18 |
-
os.makedirs(
|
| 19 |
-
|
| 20 |
-
os.chmod('/tmp/transformers_cache', 0o777)
|
| 21 |
-
os.chmod('/tmp/hf_home', 0o777)
|
| 22 |
except Exception as e:
|
| 23 |
print(f"Error setting up cache directories: {e}", file=sys.stderr)
|
| 24 |
|
|
|
|
| 9 |
app = Flask(__name__)
|
| 10 |
|
| 11 |
# Set cache directory to a location where we have write permissions
|
| 12 |
+
cache_dir = os.path.join(os.getcwd(), 'model_cache')
|
| 13 |
+
hf_home = os.path.join(os.getcwd(), 'hf_home')
|
| 14 |
+
os.environ['TRANSFORMERS_CACHE'] = cache_dir
|
| 15 |
+
os.environ['HF_HOME'] = hf_home
|
| 16 |
|
| 17 |
# Make sure the directories exist with proper permissions
|
| 18 |
try:
|
| 19 |
+
os.makedirs(cache_dir, exist_ok=True)
|
| 20 |
+
os.makedirs(hf_home, exist_ok=True)
|
| 21 |
+
print(f"Created cache directories: {cache_dir} and {hf_home}", file=sys.stderr)
|
|
|
|
|
|
|
| 22 |
except Exception as e:
|
| 23 |
print(f"Error setting up cache directories: {e}", file=sys.stderr)
|
| 24 |
|
requirements.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
flask==2.0.1
|
| 2 |
werkzeug==2.0.3
|
| 3 |
torch==2.0.1
|
| 4 |
-
numpy>=1.21.0
|
| 5 |
transformer-lens==1.2.2
|
| 6 |
transformers>=4.20.0
|
| 7 |
gunicorn==20.1.0
|
|
|
|
| 1 |
flask==2.0.1
|
| 2 |
werkzeug==2.0.3
|
| 3 |
torch==2.0.1
|
| 4 |
+
numpy>=1.21.0,<2.0.0
|
| 5 |
transformer-lens==1.2.2
|
| 6 |
transformers>=4.20.0
|
| 7 |
gunicorn==20.1.0
|