Debian Codegraph @

docker/accelerate-cpu/Dockerfile

raw
1 # Builds CPU-only Docker image of PyTorch
2 # Uses multi-staged approach to reduce size
3 # Stage 1
4 FROM python:3.10-slim as compile-image
5
6 ARG DEBIAN_FRONTEND=noninteractive
7
8 RUN apt update
9 RUN apt-get install -y --no-install-recommends \
10 build-essential \
11 git \
12 gcc
13
14 # Setup virtual environment for Docker
15 ENV VIRTUAL_ENV=/opt/venv
16 RUN python3 -m venv ${VIRTUAL_ENV}
17 # Make sure we use the virtualenv
18 ENV PATH="${VIRTUAL_ENV}/bin:$PATH"
19 WORKDIR /workspace
20 # Install specific CPU torch wheel to save on space
21 RUN python3 -m pip install --upgrade --no-cache-dir pip
22 RUN python3 -m pip install --no-cache-dir \
23 jupyter \
24 "accelerate[testing,test_trackers] @ git+https://github.com/huggingface/accelerate" \
25 --extra-index-url https://download.pytorch.org/whl/cpu
26
27 # Stage 2
28 FROM python:3.10-slim AS build-image
29 COPY --from=compile-image /opt/venv /opt/venv
30 RUN useradd -ms /bin/bash user
31 USER user
32
33 # Make sure we use the virtualenv
34 ENV PATH="/opt/venv/bin:$PATH"
35 CMD ["/bin/bash"]