Jaiwincr7 commited on
Commit
43dce44
·
1 Parent(s): 00f4b6f

FINAL FIX: Updated Dockerfile for explicit PyTorch/Accelerate installation and trimmed requirements.txt

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -11
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- # Use a Debian-based Python image. This is often more stable for PyTorch than 'slim'.
2
  FROM python:3.10
3
 
4
  # Set the working directory
@@ -7,28 +7,30 @@ WORKDIR /app
7
  # Expose the port Streamlit runs on
8
  EXPOSE 8501
9
 
10
- # Copy the requirements file and install dependencies
11
  COPY requirements.txt .
12
  COPY main.py .
13
  COPY merged.py .
14
  COPY app.py .
15
 
16
- # --- NEW INSTALLATION STEPS FOR ROBUST PYTORCH ---
17
 
18
  # 1. Upgrade pip for stability
19
  RUN pip install --upgrade pip
20
 
21
- # 2. Install PyTorch explicitly for CPU (as configured in merged.py)
22
- # This uses the specific CPU index URL, which is the most reliable way
23
- # to ensure the CPU version of PyTorch is installed without relying on
24
- # complex dependencies that might not be on the base image.
25
- RUN pip install torch --index-url https://download.pytorch.org/whl/cpu
 
 
 
26
 
27
- # 3. Install the rest of the dependencies
28
- # The original requirements.txt (excluding torch)
29
  RUN pip install -r requirements.txt
30
 
31
- # --- END NEW INSTALLATION STEPS ---
32
 
33
  # Command to run the Streamlit application
34
  CMD ["streamlit", "run", "app.py", "--server.port", "8501", "--server.address", "0.0.0.0"]
 
1
+ # Use a Debian-based Python image. This is robust for complex scientific libraries.
2
  FROM python:3.10
3
 
4
  # Set the working directory
 
7
  # Expose the port Streamlit runs on
8
  EXPOSE 8501
9
 
10
+ # Copy the requirements file and application code
11
  COPY requirements.txt .
12
  COPY main.py .
13
  COPY merged.py .
14
  COPY app.py .
15
 
16
+ # --- ROBUST DEPENDENCY INSTALLATION ---
17
 
18
  # 1. Upgrade pip for stability
19
  RUN pip install --upgrade pip
20
 
21
+ # 2. Install complex, device-dependent packages explicitly for CPU.
22
+ # This ensures that PyTorch, Accelerate, and core Hugging Face libraries
23
+ # are correctly linked and installed before other dependencies.
24
+ RUN pip install \
25
+ torch --index-url https://download.pytorch.org/whl/cpu \
26
+ accelerate \
27
+ transformers \
28
+ huggingface-hub
29
 
30
+ # 3. Install the remaining dependencies from the trimmed requirements.txt
 
31
  RUN pip install -r requirements.txt
32
 
33
+ # --- END INSTALLATION ---
34
 
35
  # Command to run the Streamlit application
36
  CMD ["streamlit", "run", "app.py", "--server.port", "8501", "--server.address", "0.0.0.0"]