-
Notifications
You must be signed in to change notification settings - Fork 15
/
Dockerfile
executable file
·139 lines (118 loc) · 4.91 KB
/
Dockerfile
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#### BEGIN: Load micromamba ####################################################
# We copy micromamba from the micromamba stage because historically the download
# link has been unreliable.
FROM mambaorg/micromamba:1.5.8-jammy as micromamba
#### END: Load micromamba ######################################################
#### BEGIN: Build spops ###################################################
# We use the devel image to build spops.
FROM nvidia/cuda:12.1.1-devel-ubuntu22.04 AS spops-build
ARG DEBIAN_FRONTEND=noninteractive
# Install utilities
RUN apt-get update -q \
&& apt-get install -y --no-install-recommends \
# Required to build spops
build-essential \
curl \
git \
sudo \
# Clean up
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Add sancho user with sudo privileges
RUN adduser --disabled-password --gecos "" sancho
RUN usermod -aG sudo sancho
RUN echo "sancho ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/sancho
# Add .local/bin to sancho PATH. Needed for pip installs.
RUN echo "export PATH=\$PATH:/home/sancho/.local/bin" >> /home/sancho/.bashrc
# Switch to sancho user
USER sancho
WORKDIR /home/sancho
# Install micromamba
# https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html#manual-installation
COPY --from=micromamba --chown=sancho /bin/micromamba .local/bin/micromamba
RUN .local/bin/micromamba shell init -s bash -p /home/sancho/micromamba
RUN .local/bin/micromamba config append channels conda-forge \
&& .local/bin/micromamba config append channels nodefaults \
&& .local/bin/micromamba config set channel_priority strict
# Set up micromamba environment
ARG MAMBA_ROOT_PREFIX=/home/sancho/.micromamba
RUN /home/sancho/.local/bin/micromamba env create -y -n panza python=3.10 \
&& /home/sancho/.local/bin/micromamba clean --all -y -f
RUN /home/sancho/.local/bin/micromamba install -n panza \
pytorch==2.2.2 pytorch-cuda=12.1 -c pytorch -c nvidia -y
# Install spops dependencies and build flash-attn
# See https://github.com/IST-DASLab/spops/blob/main/setup.py for details.
RUN /home/sancho/.local/bin/micromamba run -n panza \
pip install --no-cache-dir numpy scipy ninja pybind11
ARG TORCH_CUDA_ARCH_LIST="5.0;5.2;5.3;6.0;6.1;6.2;7.0;7.2;7.5;8.0;8.6;8.7;8.9;9.0+PTX"
RUN /home/sancho/.local/bin/micromamba run -n panza \
pip install --user --no-cache-dir \
git+https://github.com/IST-DASLab/spops.git
#### END: Build spops #####################################################
#### BEGIN: Final image ########################################################
FROM nvidia/cuda:12.1.1-base-ubuntu22.04 as final
ARG DEBIAN_FRONTEND=noninteractive
# Install utilities
RUN apt-get update -q \
&& apt-get install -y --no-install-recommends \
# General utilities
build-essential \
curl \
git \
git-lfs \
htop \
openssh-server \
sudo \
tmux \
unzip \
uuid-runtime \
vim \
wget \
# Latex
texlive-latex-extra \
texlive-fonts-recommended \
dvipng \
cm-super \
# Clean up
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Add sancho user with sudo privileges
RUN adduser --disabled-password --gecos "" sancho
RUN usermod -aG sudo sancho
RUN echo "sancho ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/sancho
# Add .local/bin to sancho PATH. Needed for pip installs.
RUN echo "export PATH=\$PATH:/home/sancho/.local/bin" >> /home/sancho/.bashrc
# Switch to sancho user
USER sancho
WORKDIR /home/sancho
# Set up git
RUN git config --global credential.helper store
RUN git config --global core.editor "vim"
# Install micromamba
# https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html#manual-installation
COPY --from=micromamba --chown=sancho /bin/micromamba .local/bin/micromamba
RUN .local/bin/micromamba shell init -s bash -p /home/sancho/micromamba
RUN .local/bin/micromamba config append channels conda-forge \
&& .local/bin/micromamba config append channels nodefaults \
&& .local/bin/micromamba config set channel_priority strict
# Create panza env
RUN /home/sancho/.local/bin/micromamba env create -y -n panza python=3.10
RUN /home/sancho/.local/bin/micromamba install -n panza \
pytorch==2.2.2 torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia -y
RUN /home/sancho/.local/bin/micromamba run -n panza \
pip install --no-cache-dir \
langdetect langchain langchain-community sentence-transformers \
faiss-cpu fire nltk gradio cmake packaging
RUN /home/sancho/.local/bin/micromamba run -n panza \
pip install --no-cache-dir \
git+https://github.com/IST-DASLab/llm-foundry
RUN /home/sancho/.local/bin/micromamba run -n panza \
pip install --no-cache-dir \
git+https://github.com/IST-DASLab/peft-rosa.git@grad_quant
# Clean up
RUN /home/sancho/.local/bin/micromamba clean --all -y -f
# Copy spops from spops-build
COPY --from=spops-build --chown=sancho \
/home/sancho/.local/lib/python3.10/site-packages \
/home/sancho/.local/lib/python3.10/site-packages
#### END: Final image ########################################################