|
10 | 10 | ARG BASE_IMAGE=ubuntu:18.04 |
11 | 11 |
|
12 | 12 | # Instal basic utilities |
13 | | -ENV DEBIAN_FRONTEND noninteractiveee |
14 | | -RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ |
15 | | - apt-get update && apt-get install -y --no-install-recommends \ |
| 13 | +FROM ${BASE_IMAGE} as dev-base |
| 14 | +RUN apt-get clean && apt-get update && apt-get upgrade && apt-get install -y --no-install-recommends \ |
16 | 15 | build-essential \ |
17 | 16 | ca-certificates \ |
18 | 17 | ccache \ |
19 | 18 | cmake \ |
20 | 19 | curl \ |
21 | 20 | git \ |
22 | 21 | gcc \ |
| 22 | + wget \ |
23 | 23 | libjpeg-dev \ |
| 24 | + zip \ |
| 25 | + swig python3-dev \ |
24 | 26 | unzip bzip2 ffmpeg libsm6 libxext6 \ |
25 | 27 | libpng-dev && \ |
26 | 28 | rm -rf /var/lib/apt/lists/* |
27 | | - |
28 | | -RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ |
29 | | - chmod +x ~/miniconda.sh && \ |
30 | | - ~/miniconda.sh -b -p /opt/conda && \ |
31 | | - rm ~/miniconda.sh && \ |
32 | | - /opt/conda/bin/conda install -c pytorch -c nvidia -y \ |
33 | | - python=${PYTHON_VERSION} \ |
34 | | - pytorch=${PYTORCH_VERSION} torchvision "pytorch-cuda=${CUDA_VERSION}" && \ |
35 | | - /opt/conda/bin/conda clean -ya |
36 | | - |
37 | 29 | RUN /usr/sbin/update-ccache-symlinks |
38 | 30 | RUN mkdir /opt/ccache && ccache --set-config=cache_dir=/opt/ccache |
39 | | - |
40 | 31 | ENV PATH /opt/conda/bin:$PATH |
| 32 | + |
| 33 | +# Instal environment |
| 34 | +FROM dev-base as conda-installs |
| 35 | +ARG PYTHON_VERSION=3.9 |
| 36 | +ARG CUDA_VERSION=11.3 |
| 37 | +ARG PYTORCH_VERSION=1.12.1 |
| 38 | +ARG CUDA_CHANNEL=nvidia |
| 39 | +ARG INSTALL_CHANNEL=pytorch |
| 40 | +ENV CONDA_OVERRIDE_CUDA=${CUDA_VERSION} |
| 41 | +RUN curl -fsSL -v -o ~/mambaforge.sh -O https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh && \ |
| 42 | + chmod +x ~/mambaforge.sh && \ |
| 43 | + ~/mambaforge.sh -b -p /opt/mamba && \ |
| 44 | + rm ~/mambaforge.sh && \ |
| 45 | + /opt/mamba/bin/mamba install -c "${INSTALL_CHANNEL}" -c "${CUDA_CHANNEL}" -y \ |
| 46 | + python=${PYTHON_VERSION} \ |
| 47 | + pytorch=${PYTORCH_VERSION} torchvision "cudatoolkit=${CUDA_VERSION}" && \ |
| 48 | + /opt/mamba/bin/mamba clean -ya |
| 49 | + |
| 50 | +ENV PATH /opt/mamba/bin:$PATH |
41 | 51 | ENV NVIDIA_VISIBLE_DEVICES all |
42 | 52 | ENV NVIDIA_DRIVER_CAPABILITIES compute,utility |
43 | 53 | ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64 |
44 | 54 | ENV PYTORCH_VERSION ${PYTORCH_VERSION} |
45 | 55 |
|
46 | | -# Install |
| 56 | +# Install dependencies |
47 | 57 | COPY ./ /workspace/ |
48 | 58 | WORKDIR /workspace/ |
49 | | -RUN /opt/conda/bin/python -m pip install -e . |
| 59 | +RUN /opt/mamba/bin/python -m pip install --upgrade pip && \ |
| 60 | + /opt/mamba/bin/python -m pip install -e .[cv,cv_classification,cv_semantic,cv_detection,nlp,nlp_retrieval,tabular,tabular_classification,dev] && \ |
| 61 | + /opt/mamba/bin/python -m pip install dvc dvc-gdrive && \ |
| 62 | + /opt/mamba/bin/python -m pip install -U timm |
| 63 | + |
| 64 | +# Pull data from GDrive |
| 65 | +RUN --mount=type=secret,id=credentials \ |
| 66 | + CREDENTIALS=$(cat /run/secrets/credentials) \ |
| 67 | + && echo "$CREDENTIALS" > /workspace/credentials.json |
| 68 | +RUN dvc remote modify gdrive --local gdrive_user_credentials_file /workspace/credentials.json |
| 69 | +RUN dvc pull |
| 70 | + |
| 71 | +ENTRYPOINT ["/bin/bash"] |
0 commit comments