-
Notifications
You must be signed in to change notification settings - Fork 449
/
Copy pathDockerfile.cuda
77 lines (47 loc) · 2.19 KB
/
Dockerfile.cuda
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
ARG http_proxy
ARG https_proxy
ARG no_proxy
FROM pytorch/pytorch:2.1.2-cuda11.8-cudnn8-runtime@sha256:971fbeae82c0a5a7a970a264a8b8ce1c3426aa79df7111004ad2bc2640f7d89c AS build_base
RUN apt-get update && apt-get install -y --no-install-recommends \
libsm6=2:1.2.3-1 \
libxext6=2:1.3.4-0ubuntu1 \
ffmpeg=7:4.2.7-0ubuntu0.1 \
libfontconfig1=2.13.1-2ubuntu3 \
libxrender1=1:0.9.10-1 \
libgl1-mesa-glx=21.2.6-0ubuntu0.1~20.04.2 \
&& rm -rf /var/lib/apt/lists/*
ARG NON_ROOT_HOME=/home/non-root
RUN useradd -l -u 10001 non-root \
&& mkdir -p ${NON_ROOT_HOME}
RUN chown -R non-root:non-root ${NON_ROOT_HOME}
ENV PATH=${PATH}:${NON_ROOT_HOME}/.local/bin
FROM build_base AS install_packages
ARG OTX_INSTALL_PATH=/opt/otx
RUN mkdir -p ${OTX_INSTALL_PATH} && chown 10001 ${OTX_INSTALL_PATH}
WORKDIR /workspace
COPY --chown=10001 . src_dir
USER non-root
RUN pip install --user --no-cache-dir --require-hashes --no-deps -r src_dir/.ci/requirements.txt && \
pip-compile --generate-hashes -o /tmp/requirements.txt src_dir/pyproject.toml
RUN pip install --no-cache-dir --no-deps --target ${OTX_INSTALL_PATH} src_dir/
ENV PYTHONPATH=${OTX_INSTALL_PATH}:${PYTHONPATH:+:${PYTHONPATH}}
ENV PATH=${OTX_INSTALL_PATH}/bin:${PATH:+:${PATH}}
RUN pip install --user --no-cache-dir --require-hashes --no-deps -r /tmp/requirements.txt && \
otx install --do-not-install-torch --user && \
rm /tmp/requirements.txt
FROM install_packages AS download_pretrained_weights
WORKDIR ${NON_ROOT_HOME}
COPY docker/download_pretrained_weights.py download_pretrained_weights.py
RUN python download_pretrained_weights.py
FROM build_base AS cuda
ARG USER_SITE=/home/non-root/.local/lib/python3.10/site-packages
ARG OTX_INSTALL_PATH=/opt/otx
ENV PYTHONPATH=${OTX_INSTALL_PATH}:${PYTHONPATH:+:${PYTHONPATH}}
ENV PATH=${OTX_INSTALL_PATH}/bin:${PATH:+:${PATH}}
COPY --chown=10001 --from=install_packages ${USER_SITE} ${USER_SITE}
COPY --chown=10001 --from=install_packages ${OTX_INSTALL_PATH} ${OTX_INSTALL_PATH}
USER non-root
WORKDIR ${NON_ROOT_HOME}
FROM cuda AS cuda_pretrained_ready
ARG TORCH_CACHE=/home/non-root/.cache/torch
COPY --chown=10001 --from=download_pretrained_weights ${TORCH_CACHE} ${TORCH_CACHE}