WSLINMSAI commited on
Commit
3675b6b
·
verified ·
1 Parent(s): 7d21e3f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +5 -5
Dockerfile CHANGED
@@ -1,27 +1,27 @@
1
  FROM python:3.10
2
 
3
  # 1. Install system dependencies
4
- # 'libgl1-mesa-glx' is deprecated, so we use 'libgl1' and 'libglib2.0-0' instead
5
  RUN apt-get update && apt-get install -y \
6
  git \
7
  libgl1 \
8
  libglib2.0-0 \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # 2. Create a user (Hugging Face Spaces best practice)
12
  RUN useradd -m -u 1000 user
13
  USER user
14
  ENV PATH="/home/user/.local/bin:$PATH"
15
 
16
- # 3. Install Torch dependencies FIRST (Isolated step)
17
  RUN pip install --no-cache-dir pip --upgrade && \
18
  pip install --no-cache-dir \
19
  torch==2.0.1+cpu \
20
  torchvision==0.15.2+cpu \
21
  --extra-index-url https://download.pytorch.org/whl/cpu
22
 
23
- # 4. Install Detectron2 (Now that Torch is ready)
24
- RUN pip install --no-cache-dir git+https://github.com/facebookresearch/detectron2.git
 
25
 
26
  # 5. Install the requirements.txt
27
  WORKDIR /app
 
1
  FROM python:3.10
2
 
3
  # 1. Install system dependencies
 
4
  RUN apt-get update && apt-get install -y \
5
  git \
6
  libgl1 \
7
  libglib2.0-0 \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
+ # 2. Create user
11
  RUN useradd -m -u 1000 user
12
  USER user
13
  ENV PATH="/home/user/.local/bin:$PATH"
14
 
15
+ # 3. Install Torch dependencies FIRST
16
  RUN pip install --no-cache-dir pip --upgrade && \
17
  pip install --no-cache-dir \
18
  torch==2.0.1+cpu \
19
  torchvision==0.15.2+cpu \
20
  --extra-index-url https://download.pytorch.org/whl/cpu
21
 
22
+ # 4. Install Detectron2 with --no-build-isolation
23
+ # This flag fixes the "No module named torch" error
24
+ RUN pip install --no-cache-dir --no-build-isolation git+https://github.com/facebookresearch/detectron2.git
25
 
26
  # 5. Install the requirements.txt
27
  WORKDIR /app