-
Notifications
You must be signed in to change notification settings - Fork 188
/
Dockerfile.chailab
executable file
·83 lines (73 loc) · 2.77 KB
/
Dockerfile.chailab
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
FROM ubuntu:22.04 AS chailab-baseimage
ENV \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
# config for apt
DEBIAN_FRONTEND=noninteractive \
# default editor for git cli
EDITOR=vim \
# keep (large) mypy cache outside of working tree
MYPY_CACHE_DIR='/tmp/.chai_lab_mypy_cache' \
# always flush output from python
PYTHONUNBUFFERED=TRUE \
# enable fault handler (print tracebacks even after segfault or NCCL errors).
PYTHONFAULTHANDLER=1 \
# keep __pycache__ out of working tree
PYTHONPYCACHEPREFIX='/tmp/.chai_lab_pycache'
RUN --mount=type=cache,target=/var/cache/apt \
apt-get -qq update \
&& apt-get -qq install -y \
# common things
gnupg ca-certificates wget git curl aria2 lsb-release tzdata \
rsync sudo tree htop tmux unzip \
clang \
# for direct ssh into container
openssh-server socat \
# provides `fuser` command
psmisc \
# RDMA/InfiniBand
libibverbs1 librdmacm1 \
# text editors, needed by git cli
nano vim \
build-essential libstdc++6 \
# python
python3.10 python3.10-dev \
# (run continues)
# stop git from complaining about dubious ownership.
&& git config --global --add safe.directory "*" \
#
# cuda softlinking is needed in podman, but not docker
&& ln -s /lib/x86_64-linux-gnu/libcuda.so.1 /lib/x86_64-linux-gnu/libcuda.so \
&& ldconfig /lib/x86_64-linux-gnu/ \
# setup timezone, to $TZ, ubuntu-specific
# && ln -fs /usr/share/zoneinfo/$TZ /etc/localtime \
&& dpkg-reconfigure --frontend noninteractive tzdata \
# change default shell to bash (has no effect during building)
&& chsh -s /bin/bash
ENV \
# expose CUDA libraries. Now that we don't build anything this is likely redundant
LD_LIBRARY_PATH="/usr/local/cuda/lib64/stubs/:${LD_LIBRARY_PATH:-}" \
# Set uv timeout to larger value to account for slow download time of nvidia-cudnn-cu12
UV_HTTP_TIMEOUT=1000 \
# where virtual env will be installed
VIRTUAL_ENV=/opt/venv
# Install dependencies in virtualenv
COPY ./requirements.in /tmp/requirements.in
# from https://pythonspeed.com/articles/activate-virtualenv-dockerfile/
# a trick to have virtualenv "always activated"
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN --mount=type=cache,target=/root/.cache/uv \
# Install uv
curl -LsSf https://astral.sh/uv/0.5.4/install.sh | sh \
&& . $HOME/.local/bin/env \
&& uv venv --no-python-downloads $VIRTUAL_ENV \
# this is sh, not bash, so . not source
&& . $VIRTUAL_ENV/bin/activate \
&& uv pip install uv pip -r /tmp/requirements.in
# making sure envvars are set in all shells
RUN echo "PATH=\"$PATH\"" >> /etc/environment \
&& echo "LANG=\"$LANG\"" >> /etc/environment \
&& echo "LC_ALL=\"$LC_ALL\"" >> /etc/environment \
&& echo "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"" >> /etc/environment \
&& echo "EDITOR=\"$EDITOR\"" >> /etc/environment
# no startup command.