This repository was archived by the owner on Jul 13, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (55 loc) · 2.8 KB
/
Copy pathDockerfile
File metadata and controls
64 lines (55 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
FROM pytorch/pytorch:2.2.2-cuda12.1-cudnn8-devel AS compile
ARG DEBIAN_FRONTEND=noninteractive
# git is required for installing flash_attn.
RUN apt update \
&& apt install -y git \
&& rm -rf /var/lib/apt/lists/*
# To port Python package installs in this stage to other Docker stages, we can
# store the installs in a virtualenv: https://stackoverflow.com/a/61879604/4865149
RUN python3 -m venv /usr/local/venv
ENV PATH="/usr/local/venv/bin:$PATH"
# Install [cuda] packages that require `nvcc`, which is available in `devel`
# PyTorch images and not `runtime` images.
COPY pyproject.toml .
RUN python3 -m pip install --no-cache-dir '.[cuda-deps]'
# CUDA_HOME is required for installing flash_attn.
ENV CUDA_HOME=/usr/local/cuda-12.1
RUN python3 -m pip install --no-cache-dir '.[cuda]'
# We use a runtime image here as the base to cut down the image size by a few
# GB, but we still consider the resulting image `dev` to be a development image
# because it contains convenience installs that aren't strictly needed for
# experiments. For simplicity we're using the same image `dev` for experiments
# and develompent.
FROM pytorch/pytorch:2.2.2-cuda12.1-cudnn8-runtime AS dev
ARG DEBIAN_FRONTEND=noninteractive
# Install some useful packages
RUN apt update \
&& apt install -y rsync git parallel vim tini wget curl inotify-tools libsndfile1-dev tesseract-ocr espeak-ng python3 python3-pip ffmpeg zstd gcc \
&& rm -rf /var/lib/apt/lists/* \
&& python3 -m pip install --upgrade --no-cache-dir pip requests
# VSCode code server
RUN curl -fsSL https://code-server.dev/install.sh | sh
ENV PATH="/home/coder/.local/bin:${PATH}"
RUN code-server --install-extension ms-python.python
RUN code-server --install-extension ms-pyright.pyright
RUN code-server --install-extension ms-python.black-formatter
# URL is from https://marketplace.visualstudio.com/items?itemName=GitHub.copilot&ssr=false#version-history
RUN wget https://marketplace.visualstudio.com/_apis/public/gallery/publishers/GitHub/vsextensions/copilot/1.243.1189/vspackage --output-document copilot.vsix.gz \
&& gzip --decompress copilot.vsix.gz \
&& code-server --install-extension copilot.vsix \
&& rm copilot.vsix
# Copy the venv with built packages from compile stage
COPY --from=compile /usr/local/venv /usr/local/venv
ENV PATH="/usr/local/venv/bin:$PATH"
COPY pyproject.toml /workspace/robust-llm/
WORKDIR /workspace
# Install in developer mode with a mock dependency-only project.
# This installs dependencies, and makes `robust_llm` importable from
# `/workspace/robust-llm`. We then remove that directory: the user
# needs to install a real version of the code (e.g. by Git cloning it).
RUN cd robust-llm \
&& mkdir robust_llm \
&& touch robust_llm/__init__.py \
&& python3 -m pip install --no-cache-dir -e ".[dev]" \
&& cd .. \
&& rm -rf robust-llm