Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +24 -48
Dockerfile
CHANGED
|
@@ -14,111 +14,87 @@ RUN apt-get update && apt-get install -y \
|
|
| 14 |
libgl1-mesa-glx \
|
| 15 |
libglib2.0-0 \
|
| 16 |
python3-dev \
|
| 17 |
-
#cuda-toolkit-12-1 \
|
| 18 |
g++ \
|
| 19 |
&& rm -rf /var/lib/apt/lists/*
|
| 20 |
|
| 21 |
-
|
| 22 |
-
RUN ln -s /usr/bin/python3 /usr/bin/python
|
| 23 |
|
| 24 |
-
# Create a non-root user
|
| 25 |
RUN useradd -m -u 1000 user
|
| 26 |
-
|
| 27 |
USER user
|
| 28 |
|
| 29 |
-
# Verify CUDA installation path
|
| 30 |
-
RUN find /usr/local -type d -name "cuda*"
|
| 31 |
-
|
| 32 |
ENV HOME=/home/user \
|
| 33 |
PATH=/home/user/.local/bin:$PATH \
|
| 34 |
-
PYTHONPATH=
|
| 35 |
PYTHONUNBUFFERED=1 \
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
GRADIO_SHARE=False \
|
| 41 |
-
|
| 42 |
|
| 43 |
-
# Set CUDA_HOME environment variable
|
| 44 |
ENV CUDA_HOME=/usr/local/cuda-11.8
|
| 45 |
ENV TORCH_CUDA_ARCH_LIST="6.0;6.1;7.0;7.5;8.0;8.6+PTX;8.9;9.0"
|
| 46 |
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
|
| 47 |
-
|
| 48 |
-
# Set the environment variable to specify the GPU device
|
| 49 |
ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
|
| 50 |
ENV CUDA_VISIBLE_DEVICES=0
|
| 51 |
|
| 52 |
-
# Clone the RB-Modulation repository
|
| 53 |
RUN git clone https://github.com/google/RB-Modulation.git $HOME/app
|
| 54 |
|
| 55 |
-
# Ensure CSD directory exists and is in the correct location
|
| 56 |
RUN if [ ! -d "$HOME/app/third_party/CSD" ]; then \
|
| 57 |
echo "CSD directory not found in the expected location" && \
|
| 58 |
exit 1; \
|
| 59 |
fi
|
| 60 |
|
| 61 |
-
# Set the working directory
|
| 62 |
WORKDIR $HOME/app
|
| 63 |
|
| 64 |
-
RUN python3 -m pip install --upgrade pip
|
| 65 |
|
| 66 |
-
# Download pretrained models
|
| 67 |
RUN cd third_party/StableCascade/models && \
|
| 68 |
-
bash download_models.sh essential big-big bfloat16
|
| 69 |
-
cd ../../..
|
| 70 |
|
| 71 |
-
# Install StableCascade requirements
|
| 72 |
RUN cd third_party/StableCascade && \
|
| 73 |
pip install --no-cache-dir -r requirements.txt && \
|
| 74 |
-
pip install --no-cache-dir jupyter notebook opencv-python matplotlib ftfy
|
| 75 |
-
cd ../..
|
| 76 |
|
| 77 |
-
# Install gdown for Google Drive downloads
|
| 78 |
RUN pip install --no-cache-dir gdown
|
| 79 |
|
| 80 |
-
# Download pre-trained CSD weights
|
| 81 |
RUN gdown https://drive.google.com/uc?id=1FX0xs8p-C7Ob-h5Y4cUhTeOepHzXv_46 -O $HOME/app/third_party/CSD/checkpoint.pth
|
| 82 |
|
| 83 |
-
# Verify the download
|
| 84 |
RUN if [ ! -f "$HOME/app/third_party/CSD/checkpoint.pth" ]; then \
|
| 85 |
echo "CSD checkpoint file not found" && exit 1; \
|
| 86 |
fi
|
| 87 |
|
| 88 |
RUN ls -la $HOME/app/third_party/CSD
|
| 89 |
-
|
| 90 |
-
# Ensure CSD is a proper Python package
|
| 91 |
RUN touch $HOME/app/third_party/CSD/__init__.py
|
| 92 |
|
| 93 |
-
# Update PYTHONPATH
|
| 94 |
ENV PYTHONPATH=$HOME/app:$HOME/app/third_party:$PYTHONPATH
|
| 95 |
|
| 96 |
-
# Print Python path
|
| 97 |
RUN python -c "import sys; print('\n'.join(sys.path))"
|
| 98 |
|
| 99 |
-
RUN pip install --no-cache-dir pybind11>=2.12
|
| 100 |
-
|
| 101 |
-
|
| 102 |
|
| 103 |
-
# Verify CSD module can be imported (try different methods)
|
| 104 |
RUN python -c "from third_party.CSD import model; print('CSD model successfully imported')" || \
|
| 105 |
python -c "import sys; sys.path.append('/home/user/app/third_party'); from CSD import model; print('CSD model successfully imported')"
|
| 106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
pip install --no-cache-dir segment-anything==1.0 && \
|
| 111 |
-
git clone https://github.com/luca-medeiros/lang-segment-anything && \
|
| 112 |
-
cd lang-segment-anything && \
|
| 113 |
git checkout 9bdf77715fa70fca96452184abdc64a6666e0d46 && \
|
| 114 |
-
pip install -e .
|
| 115 |
-
cd ..
|
| 116 |
|
| 117 |
-
# Upgrade pip and install Gradio
|
| 118 |
RUN python3 -m pip install --no-cache-dir gradio==6.13.0 accelerate==1.0.1
|
| 119 |
|
| 120 |
-
# Copy the app.py file from the host to the container
|
| 121 |
COPY --chown=user:user app.py .
|
| 122 |
|
| 123 |
-
# Command to run the Gradio app
|
| 124 |
CMD ["python3", "app.py"]
|
|
|
|
| 14 |
libgl1-mesa-glx \
|
| 15 |
libglib2.0-0 \
|
| 16 |
python3-dev \
|
|
|
|
| 17 |
g++ \
|
| 18 |
&& rm -rf /var/lib/apt/lists/*
|
| 19 |
|
| 20 |
+
RUN ln -s /usr/bin/python3 /usr/bin/python || true
|
|
|
|
| 21 |
|
|
|
|
| 22 |
RUN useradd -m -u 1000 user
|
|
|
|
| 23 |
USER user
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
ENV HOME=/home/user \
|
| 26 |
PATH=/home/user/.local/bin:$PATH \
|
| 27 |
+
PYTHONPATH=/home/user/app \
|
| 28 |
PYTHONUNBUFFERED=1 \
|
| 29 |
+
GRADIO_ALLOW_FLAGGING=never \
|
| 30 |
+
GRADIO_NUM_PORTS=1 \
|
| 31 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 32 |
+
GRADIO_THEME=huggingface \
|
| 33 |
GRADIO_SHARE=False \
|
| 34 |
+
SYSTEM=spaces
|
| 35 |
|
|
|
|
| 36 |
ENV CUDA_HOME=/usr/local/cuda-11.8
|
| 37 |
ENV TORCH_CUDA_ARCH_LIST="6.0;6.1;7.0;7.5;8.0;8.6+PTX;8.9;9.0"
|
| 38 |
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
|
|
|
|
|
|
|
| 39 |
ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
|
| 40 |
ENV CUDA_VISIBLE_DEVICES=0
|
| 41 |
|
|
|
|
| 42 |
RUN git clone https://github.com/google/RB-Modulation.git $HOME/app
|
| 43 |
|
|
|
|
| 44 |
RUN if [ ! -d "$HOME/app/third_party/CSD" ]; then \
|
| 45 |
echo "CSD directory not found in the expected location" && \
|
| 46 |
exit 1; \
|
| 47 |
fi
|
| 48 |
|
|
|
|
| 49 |
WORKDIR $HOME/app
|
| 50 |
|
| 51 |
+
RUN python3 -m pip install --upgrade pip setuptools wheel
|
| 52 |
|
|
|
|
| 53 |
RUN cd third_party/StableCascade/models && \
|
| 54 |
+
bash download_models.sh essential big-big bfloat16
|
|
|
|
| 55 |
|
|
|
|
| 56 |
RUN cd third_party/StableCascade && \
|
| 57 |
pip install --no-cache-dir -r requirements.txt && \
|
| 58 |
+
pip install --no-cache-dir jupyter notebook opencv-python matplotlib ftfy
|
|
|
|
| 59 |
|
|
|
|
| 60 |
RUN pip install --no-cache-dir gdown
|
| 61 |
|
|
|
|
| 62 |
RUN gdown https://drive.google.com/uc?id=1FX0xs8p-C7Ob-h5Y4cUhTeOepHzXv_46 -O $HOME/app/third_party/CSD/checkpoint.pth
|
| 63 |
|
|
|
|
| 64 |
RUN if [ ! -f "$HOME/app/third_party/CSD/checkpoint.pth" ]; then \
|
| 65 |
echo "CSD checkpoint file not found" && exit 1; \
|
| 66 |
fi
|
| 67 |
|
| 68 |
RUN ls -la $HOME/app/third_party/CSD
|
|
|
|
|
|
|
| 69 |
RUN touch $HOME/app/third_party/CSD/__init__.py
|
| 70 |
|
|
|
|
| 71 |
ENV PYTHONPATH=$HOME/app:$HOME/app/third_party:$PYTHONPATH
|
| 72 |
|
|
|
|
| 73 |
RUN python -c "import sys; print('\n'.join(sys.path))"
|
| 74 |
|
| 75 |
+
RUN pip install --no-cache-dir pybind11>=2.12
|
| 76 |
+
RUN pip install --no-cache-dir numpy==1.26.4
|
| 77 |
+
RUN pip install --no-cache-dir transformers==4.31.0
|
| 78 |
|
|
|
|
| 79 |
RUN python -c "from third_party.CSD import model; print('CSD model successfully imported')" || \
|
| 80 |
python -c "import sys; sys.path.append('/home/user/app/third_party'); from CSD import model; print('CSD model successfully imported')"
|
| 81 |
|
| 82 |
+
# Vérifie que torch est bien dispo avant GroundingDINO
|
| 83 |
+
RUN python -c "import torch; print('torch ok:', torch.__version__)"
|
| 84 |
+
|
| 85 |
+
# Install LangSAM dependencies
|
| 86 |
+
RUN pip install --no-cache-dir segment-anything==1.0
|
| 87 |
+
|
| 88 |
+
# Fix principal: désactiver le build isolation pour GroundingDINO
|
| 89 |
+
RUN pip install --no-cache-dir --no-build-isolation git+https://github.com/IDEA-Research/GroundingDINO.git
|
| 90 |
|
| 91 |
+
RUN git clone https://github.com/luca-medeiros/lang-segment-anything /tmp/lang-segment-anything && \
|
| 92 |
+
cd /tmp/lang-segment-anything && \
|
|
|
|
|
|
|
|
|
|
| 93 |
git checkout 9bdf77715fa70fca96452184abdc64a6666e0d46 && \
|
| 94 |
+
pip install -e .
|
|
|
|
| 95 |
|
|
|
|
| 96 |
RUN python3 -m pip install --no-cache-dir gradio==6.13.0 accelerate==1.0.1
|
| 97 |
|
|
|
|
| 98 |
COPY --chown=user:user app.py .
|
| 99 |
|
|
|
|
| 100 |
CMD ["python3", "app.py"]
|