Update Dockerfile to pin numpy and adjust PyTorch installation method for compatibility with pip, ensuring proper handling of dependencies from PyPI and the PyTorch index.
Browse files- S2FApp/Dockerfile +7 -2
S2FApp/Dockerfile
CHANGED
|
@@ -18,9 +18,14 @@ COPY requirements.txt requirements-docker.txt ./
|
|
| 18 |
# Install Python dependencies - CPU-only PyTorch to fit Space memory limits (avoids OOM)
|
| 19 |
# (psutil removed from requirements-docker.txt — optional CPU/RAM widget not used in app)
|
| 20 |
# PyTorch 2.2 + torchvision 0.17 (CPU) - match requirements.txt torch>=2.0
|
| 21 |
-
# Install numpy first with compatible version (<2) so torch.from_numpy works
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
RUN pip install --no-cache-dir "numpy>=1.20.0,<2.0" && \
|
| 23 |
-
pip install --no-cache-dir torch==2.2.0 torchvision==0.17.0
|
|
|
|
| 24 |
pip install --no-cache-dir -r requirements-docker.txt
|
| 25 |
|
| 26 |
# Copy app code (chown for HF Spaces permissions)
|
|
|
|
| 18 |
# Install Python dependencies - CPU-only PyTorch to fit Space memory limits (avoids OOM)
|
| 19 |
# (psutil removed from requirements-docker.txt — optional CPU/RAM widget not used in app)
|
| 20 |
# PyTorch 2.2 + torchvision 0.17 (CPU) - match requirements.txt torch>=2.0
|
| 21 |
+
# Install numpy first with compatible version (<2) so torch.from_numpy works.
|
| 22 |
+
# Pin the +cpu local version and use --extra-index-url (not --index-url) so pip
|
| 23 |
+
# still uses PyPI for dependencies. --index-url hides PyPI; the PyTorch index then
|
| 24 |
+
# serves typing-extensions/jinja2 wheels that current pip rejects ("inconsistent
|
| 25 |
+
# Name"), and the source fallback cannot find flit_core.
|
| 26 |
RUN pip install --no-cache-dir "numpy>=1.20.0,<2.0" && \
|
| 27 |
+
pip install --no-cache-dir "torch==2.2.0+cpu" "torchvision==0.17.0+cpu" \
|
| 28 |
+
--extra-index-url https://download.pytorch.org/whl/cpu && \
|
| 29 |
pip install --no-cache-dir -r requirements-docker.txt
|
| 30 |
|
| 31 |
# Copy app code (chown for HF Spaces permissions)
|