jmanhype
commited on
Commit
Β·
30fab3d
1
Parent(s):
3b79a60
Update Dockerfile and entrypoint script with compatible package versions and proper environment setup
Browse files- Dockerfile +63 -167
- scripts/gradio/entrypoint.sh +8 -6
Dockerfile
CHANGED
@@ -1,176 +1,72 @@
|
|
1 |
-
FROM
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
-
LABEL Description="Test dockerfile for Hugging Face Space"
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
# Install essential packages first
|
10 |
RUN apt-get update && apt-get install -y \
|
11 |
-
|
|
|
|
|
12 |
git \
|
13 |
-
|
14 |
-
libsm6 \
|
15 |
-
libxext6 \
|
16 |
-
ninja-build \
|
17 |
build-essential \
|
18 |
g++ \
|
19 |
-
cmake \
|
20 |
&& rm -rf /var/lib/apt/lists/*
|
21 |
|
22 |
-
#
|
23 |
-
RUN useradd -m -
|
24 |
-
|
25 |
-
# Set home to the user's home directory
|
26 |
-
ENV HOME=/home/user \
|
27 |
-
PATH=/home/user/.local/bin:$PATH
|
28 |
-
|
29 |
-
# Create the directory structure and set permissions
|
30 |
-
RUN mkdir -p /home/user/app/scripts/gradio && \
|
31 |
-
chown -R user:user /home/user/app
|
32 |
-
|
33 |
-
# Switch to the "user" user
|
34 |
USER user
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
PyYAML \
|
89 |
-
scipy \
|
90 |
-
tqdm \
|
91 |
-
albumentations==1.3.1 \
|
92 |
-
opencv-contrib-python==4.8.0.76 \
|
93 |
-
imageio-ffmpeg==0.4.8 \
|
94 |
-
pytorch-lightning==2.0.8 \
|
95 |
-
timm==0.9.12 \
|
96 |
-
safetensors==0.3.3 \
|
97 |
-
pycocotools \
|
98 |
-
kornia==0.7.0 \
|
99 |
-
open_clip_torch==2.20.0 \
|
100 |
-
torchmetrics==1.1.1 \
|
101 |
-
invisible-watermark==0.1.5 \
|
102 |
-
ftfy==6.1.1 \
|
103 |
-
loguru==0.6.0 \
|
104 |
-
markupsafe==2.0.1 \
|
105 |
-
cuid
|
106 |
-
|
107 |
-
# Install MMCM dependencies first
|
108 |
-
RUN conda run -n musev pip install --no-cache-dir basicsr && \
|
109 |
-
conda run -n musev pip install --no-cache-dir -U openmim && \
|
110 |
-
conda run -n musev mim install mmengine && \
|
111 |
-
conda run -n musev mim install "mmcv>=2.0.1" && \
|
112 |
-
conda run -n musev mim install "mmdet>=3.1.0" && \
|
113 |
-
conda run -n musev mim install "mmpose>=1.1.0"
|
114 |
-
|
115 |
-
# Install git dependencies incrementally
|
116 |
-
# First install diffusers from PyPI to get dependencies right
|
117 |
-
RUN conda run -n musev pip install --no-cache-dir "diffusers==0.21.4"
|
118 |
-
# Then install the custom version
|
119 |
-
RUN cd /tmp && \
|
120 |
-
git clone https://github.com/TMElyralab/diffusers.git && \
|
121 |
-
cd diffusers && \
|
122 |
-
git checkout main && \
|
123 |
-
conda run -n musev pip install -e .
|
124 |
-
|
125 |
-
RUN conda run -n musev pip install --no-cache-dir git+https://github.com/tencent-ailab/IP-Adapter.git@main
|
126 |
-
RUN conda run -n musev pip install --no-cache-dir git+https://github.com/openai/CLIP.git@main
|
127 |
-
RUN conda run -n musev pip install --no-cache-dir git+https://github.com/TMElyralab/controlnet_aux.git@tme
|
128 |
-
|
129 |
-
# Now install MMCM after its dependencies are installed
|
130 |
-
RUN git clone https://github.com/TMElyralab/MMCM.git /tmp/mmcm && \
|
131 |
-
cd /tmp/mmcm && \
|
132 |
-
git checkout setup && \
|
133 |
-
conda run -n musev pip install -e .
|
134 |
-
|
135 |
-
# Create entrypoint script
|
136 |
-
RUN printf '#!/bin/bash\n\
|
137 |
-
echo "entrypoint.sh"\n\
|
138 |
-
whoami\n\
|
139 |
-
which python\n\
|
140 |
-
\n\
|
141 |
-
# Set up Python path\n\
|
142 |
-
export PYTHONPATH=${PYTHONPATH}:/home/user/app:/home/user/app/MMCM:/home/user/app/diffusers/src:/home/user/app/controlnet_aux/src\n\
|
143 |
-
echo "pythonpath" $PYTHONPATH\n\
|
144 |
-
\n\
|
145 |
-
# Activate conda environment\n\
|
146 |
-
source /opt/conda/etc/profile.d/conda.sh\n\
|
147 |
-
conda activate musev\n\
|
148 |
-
\n\
|
149 |
-
# Print Python version and location\n\
|
150 |
-
which python\n\
|
151 |
-
python --version\n\
|
152 |
-
\n\
|
153 |
-
# Run the app\n\
|
154 |
-
cd /home/user/app\n\
|
155 |
-
python scripts/gradio/app_gradio_space.py\n' > $HOME/app/scripts/gradio/entrypoint.sh
|
156 |
-
|
157 |
-
# Make the script executable
|
158 |
-
RUN chmod +x $HOME/app/scripts/gradio/entrypoint.sh && \
|
159 |
-
cat $HOME/app/scripts/gradio/entrypoint.sh
|
160 |
-
|
161 |
-
# Set up Python path
|
162 |
-
ENV PYTHONPATH=$PYTHONPATH:$HOME/app:$HOME/app/MMCM:$HOME/app/diffusers/src:$HOME/app/controlnet_aux/src
|
163 |
-
|
164 |
-
# Verify final setup
|
165 |
-
RUN echo "=== Final directory structure ===" && \
|
166 |
-
ls -la scripts/gradio/ && \
|
167 |
-
echo "=== Python path ===" && \
|
168 |
-
echo $PYTHONPATH && \
|
169 |
-
echo "=== Entrypoint script location ===" && \
|
170 |
-
ls -la $HOME/app/scripts/gradio/entrypoint.sh
|
171 |
-
|
172 |
-
EXPOSE 7860
|
173 |
-
|
174 |
-
# Set working directory to app root
|
175 |
-
WORKDIR $HOME/app
|
176 |
-
CMD ["./scripts/gradio/entrypoint.sh"]
|
|
|
1 |
+
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
|
2 |
|
3 |
+
# Prevent interactive prompts during package installation
|
4 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
5 |
|
6 |
+
# Install system dependencies
|
|
|
|
|
7 |
RUN apt-get update && apt-get install -y \
|
8 |
+
python3.10 \
|
9 |
+
python3.10-dev \
|
10 |
+
python3-pip \
|
11 |
git \
|
12 |
+
wget \
|
|
|
|
|
|
|
13 |
build-essential \
|
14 |
g++ \
|
|
|
15 |
&& rm -rf /var/lib/apt/lists/*
|
16 |
|
17 |
+
# Create a non-root user
|
18 |
+
RUN useradd -m -s /bin/bash user
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
USER user
|
20 |
+
WORKDIR /home/user
|
21 |
+
|
22 |
+
# Set up Python environment
|
23 |
+
ENV PATH="/home/user/.local/bin:${PATH}"
|
24 |
+
RUN python3.10 -m pip install --user --no-cache-dir --upgrade pip
|
25 |
+
|
26 |
+
# Install conda
|
27 |
+
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \
|
28 |
+
bash miniconda.sh -b -p /home/user/.conda && \
|
29 |
+
rm miniconda.sh
|
30 |
+
ENV PATH="/home/user/.conda/bin:${PATH}"
|
31 |
+
|
32 |
+
# Create and activate conda environment
|
33 |
+
RUN conda create -n musev python=3.10 -y
|
34 |
+
SHELL ["conda", "run", "-n", "musev", "/bin/bash", "-c"]
|
35 |
+
|
36 |
+
# Install specific versions of key packages
|
37 |
+
RUN pip install --no-cache-dir \
|
38 |
+
setuptools==65.5.1 \
|
39 |
+
huggingface_hub==0.14.1 \
|
40 |
+
transformers==4.30.2 \
|
41 |
+
accelerate==0.20.3
|
42 |
+
|
43 |
+
# Clone repositories
|
44 |
+
RUN cd /home/user && \
|
45 |
+
git clone https://github.com/jmanhype/MMCM.git && \
|
46 |
+
git clone https://github.com/jmanhype/diffusers.git -b main && \
|
47 |
+
git clone https://github.com/patrickvonplaten/controlnet_aux.git
|
48 |
+
|
49 |
+
# Install dependencies
|
50 |
+
RUN pip install --no-cache-dir openmim && \
|
51 |
+
cd /home/user/MMCM && pip install --no-cache-dir -e . && \
|
52 |
+
cd /home/user/diffusers && pip install --no-cache-dir -e . && \
|
53 |
+
cd /home/user/controlnet_aux && pip install --no-cache-dir -e .
|
54 |
+
|
55 |
+
# Clone and set up app
|
56 |
+
RUN cd /home/user && \
|
57 |
+
git clone https://github.com/jmanhype/MuseV.git app
|
58 |
+
|
59 |
+
# Install remaining requirements
|
60 |
+
COPY requirements.txt /home/user/
|
61 |
+
RUN pip install --no-cache-dir -r /home/user/requirements.txt
|
62 |
+
|
63 |
+
# Set up entrypoint
|
64 |
+
COPY scripts/gradio/entrypoint.sh /home/user/
|
65 |
+
RUN chmod +x /home/user/entrypoint.sh
|
66 |
+
|
67 |
+
# Set environment variables
|
68 |
+
ENV PYTHONPATH=/home/user/app:/home/user/app/MMCM:/home/user/app/diffusers/src:/home/user/app/controlnet_aux/src
|
69 |
+
|
70 |
+
# Set working directory and entrypoint
|
71 |
+
WORKDIR /home/user/app
|
72 |
+
ENTRYPOINT ["/home/user/entrypoint.sh"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/gradio/entrypoint.sh
CHANGED
@@ -2,19 +2,21 @@
|
|
2 |
|
3 |
echo "entrypoint.sh"
|
4 |
whoami
|
5 |
-
which python
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
echo "pythonpath
|
10 |
|
11 |
# Activate conda environment
|
12 |
-
source /opt/conda/etc/profile.d/conda.sh
|
13 |
conda activate musev
|
14 |
|
15 |
# Print Python version and location
|
16 |
which python
|
17 |
python --version
|
18 |
|
|
|
|
|
|
|
19 |
# Run the app
|
20 |
-
|
|
|
|
2 |
|
3 |
echo "entrypoint.sh"
|
4 |
whoami
|
|
|
5 |
|
6 |
+
# Print Python location
|
7 |
+
which python
|
8 |
+
echo "pythonpath :$PYTHONPATH"
|
9 |
|
10 |
# Activate conda environment
|
|
|
11 |
conda activate musev
|
12 |
|
13 |
# Print Python version and location
|
14 |
which python
|
15 |
python --version
|
16 |
|
17 |
+
# Install any pending dependencies
|
18 |
+
pip install --no-cache-dir -U openmim
|
19 |
+
|
20 |
# Run the app
|
21 |
+
cd /home/user/app
|
22 |
+
python scripts/gradio/app_gradio_space.py
|