Spaces:
Runtime error
Runtime error
Commit
·
2cdedb8
1
Parent(s):
5d1de0c
chore: Update Dockerfile to install pciutils for GPU detection
Browse files- Dockerfile +23 -7
- check_gpu.sh +7 -0
Dockerfile
CHANGED
|
@@ -3,8 +3,7 @@ FROM nvidia/cuda:11.3.1-base-ubuntu20.04
|
|
| 3 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 4 |
TZ=Europe/Paris
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
# Install some basic utilities
|
| 8 |
RUN rm -f /etc/apt/sources.list.d/*.list && \
|
| 9 |
apt-get update && apt-get install -y --no-install-recommends \
|
| 10 |
curl \
|
|
@@ -20,6 +19,7 @@ RUN rm -f /etc/apt/sources.list.d/*.list && \
|
|
| 20 |
build-essential \
|
| 21 |
libsndfile-dev \
|
| 22 |
software-properties-common \
|
|
|
|
| 23 |
&& rm -rf /var/lib/apt/lists/*
|
| 24 |
|
| 25 |
RUN add-apt-repository ppa:flexiondotorg/nvtop && \
|
|
@@ -63,11 +63,24 @@ USER root
|
|
| 63 |
|
| 64 |
# User Debian packages
|
| 65 |
## Security warning : Potential user code executed as root (build time)
|
| 66 |
-
|
| 67 |
-
|
| 68 |
xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
|
| 69 |
&& rm -rf /var/lib/apt/lists/*
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
# Copy notebooks directory to a temporary location
|
| 72 |
COPY --chown=user notebooks /home/user/notebooks
|
| 73 |
|
|
@@ -78,9 +91,12 @@ COPY --chown=user notebooks /home/user/notebooks
|
|
| 78 |
USER user
|
| 79 |
|
| 80 |
# Python packages
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
| 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
|
|
|
|
| 3 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 4 |
TZ=Europe/Paris
|
| 5 |
|
| 6 |
+
# Install some basic utilities and packages for GPU detection
|
|
|
|
| 7 |
RUN rm -f /etc/apt/sources.list.d/*.list && \
|
| 8 |
apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
curl \
|
|
|
|
| 19 |
build-essential \
|
| 20 |
libsndfile-dev \
|
| 21 |
software-properties-common \
|
| 22 |
+
pciutils \
|
| 23 |
&& rm -rf /var/lib/apt/lists/*
|
| 24 |
|
| 25 |
RUN add-apt-repository ppa:flexiondotorg/nvtop && \
|
|
|
|
| 63 |
|
| 64 |
# User Debian packages
|
| 65 |
## Security warning : Potential user code executed as root (build time)
|
| 66 |
+
COPY packages.txt /root/packages.txt
|
| 67 |
+
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 |
+
# Conditional installation based on GPU availability
|
| 76 |
+
RUN if /root/check_gpu.sh; then \
|
| 77 |
+
echo "GPU detected. Installing GPU-specific Python packages." && \
|
| 78 |
+
cp /home/user/notebooks/requirements_gpu.txt /home/user/requirements_specific.txt; \
|
| 79 |
+
else \
|
| 80 |
+
echo "No GPU detected. Installing CPU-specific Python packages." && \
|
| 81 |
+
cp /home/user/notebooks/requirements_cpu.txt /home/user/requirements_specific.txt; \
|
| 82 |
+
fi
|
| 83 |
+
|
| 84 |
# Copy notebooks directory to a temporary location
|
| 85 |
COPY --chown=user notebooks /home/user/notebooks
|
| 86 |
|
|
|
|
| 91 |
USER user
|
| 92 |
|
| 93 |
# Python packages
|
| 94 |
+
COPY base_requirements.txt /home/user/base_requirements.txt
|
| 95 |
+
COPY notebooks/requirements.txt /home/user/notebooks/requirements.txt
|
| 96 |
+
COPY notebooks/requirements_cpu.txt /home/user/notebooks/requirements_cpu.txt
|
| 97 |
+
COPY notebooks/requirements_gpu.txt /home/user/notebooks/requirements_gpu.txt
|
| 98 |
+
|
| 99 |
+
RUN pip install --no-cache-dir --upgrade -r /home/user/base_requirements.txt -r /home/user/requirements_specific.txt
|
| 100 |
|
| 101 |
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 102 |
COPY --chown=user . $HOME/app
|
check_gpu.sh
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
if lspci | grep -i nvidia; then
|
| 4 |
+
exit 0
|
| 5 |
+
else
|
| 6 |
+
exit 1
|
| 7 |
+
fi
|