Commit
•
55e4b8f
1
Parent(s):
f0c2c24
detect GPU during start_server step
Browse files- Dockerfile +1 -14
- start_server.sh +9 -0
Dockerfile
CHANGED
@@ -68,23 +68,10 @@ RUN apt-get update && \
|
|
68 |
xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
|
69 |
&& rm -rf /var/lib/apt/lists/*
|
70 |
|
71 |
-
# Script to check for GPU
|
72 |
-
COPY check_gpu.sh /root/check_gpu.sh
|
73 |
-
RUN chmod +x /root/check_gpu.sh
|
74 |
-
|
75 |
# Copy notebook requirement files
|
76 |
COPY notebooks/requirements_cpu.txt /home/user/notebooks/requirements_cpu.txt
|
77 |
COPY notebooks/requirements_gpu.txt /home/user/notebooks/requirements_gpu.txt
|
78 |
|
79 |
-
# Conditional installation based on GPU availability
|
80 |
-
RUN if /root/check_gpu.sh; then \
|
81 |
-
echo "GPU detected. Installing GPU-specific Python packages." && \
|
82 |
-
cp /home/user/notebooks/requirements_gpu.txt /home/user/requirements_specific.txt; \
|
83 |
-
else \
|
84 |
-
echo "No GPU detected. Installing CPU-specific Python packages." && \
|
85 |
-
cp /home/user/notebooks/requirements_cpu.txt /home/user/requirements_specific.txt; \
|
86 |
-
fi
|
87 |
-
|
88 |
#######################################
|
89 |
# End root user section
|
90 |
#######################################
|
@@ -93,7 +80,7 @@ USER user
|
|
93 |
|
94 |
# Python packages
|
95 |
COPY base_requirements.txt /home/user/base_requirements.txt
|
96 |
-
RUN pip install --no-cache-dir --upgrade -r /home/user/base_requirements.txt
|
97 |
|
98 |
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
99 |
COPY --chown=user . $HOME/app
|
|
|
68 |
xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
|
69 |
&& rm -rf /var/lib/apt/lists/*
|
70 |
|
|
|
|
|
|
|
|
|
71 |
# Copy notebook requirement files
|
72 |
COPY notebooks/requirements_cpu.txt /home/user/notebooks/requirements_cpu.txt
|
73 |
COPY notebooks/requirements_gpu.txt /home/user/notebooks/requirements_gpu.txt
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
#######################################
|
76 |
# End root user section
|
77 |
#######################################
|
|
|
80 |
|
81 |
# Python packages
|
82 |
COPY base_requirements.txt /home/user/base_requirements.txt
|
83 |
+
RUN pip install --no-cache-dir --upgrade -r /home/user/base_requirements.txt
|
84 |
|
85 |
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
86 |
COPY --chown=user . $HOME/app
|
start_server.sh
CHANGED
@@ -27,6 +27,15 @@ for file in /home/user/notebooks/**/*; do
|
|
27 |
fi
|
28 |
done
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
|
31 |
|
32 |
echo "Starting Jupyter Lab with token $JUPYTER_TOKEN"
|
|
|
27 |
fi
|
28 |
done
|
29 |
|
30 |
+
# GPU detection and package installation
|
31 |
+
if command -v nvidia-smi &> /dev/null && nvidia-smi -L; then
|
32 |
+
echo "GPU detected. Installing GPU-specific Python packages."
|
33 |
+
pip install --no-cache-dir -r /home/user/notebooks/requirements_gpu.txt
|
34 |
+
else
|
35 |
+
echo "No GPU detected. Installing CPU-specific Python packages."
|
36 |
+
pip install --no-cache-dir -r /home/user/notebooks/requirements_cpu.txt
|
37 |
+
fi
|
38 |
+
|
39 |
JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
|
40 |
|
41 |
echo "Starting Jupyter Lab with token $JUPYTER_TOKEN"
|