@@ -2,6 +2,8 @@ ARG BASE_IMAGE=nvidia/cuda:11.3.1-devel-ubuntu18.04
22
33FROM ${BASE_IMAGE} as dev-base
44
5+ SHELL ["/bin/bash" , "-c" ]
6+
57# Install system dependencies
68RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
79 apt update && DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends \
@@ -39,7 +41,9 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
3941 apt-transport-https \
4042 ca-certificates \
4143 gnupg \
42- software-properties-common && \
44+ software-properties-common \
45+ python-pip \
46+ python3-pip && \
4347 wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \
4448 apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \
4549 echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \
@@ -56,43 +60,51 @@ WORKDIR /opt/multipy
5660COPY . .
5761RUN git submodule update --init --recursive --jobs 0
5862
59- # install pyenv
60- FROM dev-base as pyenv-install
61- RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \
62- export PYENV_ROOT="~/.pyenv" && \
63- export PATH="$PYENV_ROOT/bin:$PATH"
64- # dummy cmd to verify installation.
65- RUN pyenv install --list
66-
67- # Install conda + neccessary python dependencies
68- FROM dev-base as conda
69- ARG PYTHON_VERSION=3.8
70- RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
63+ # Install conda/pyenv + necessary python dependencies
64+ FROM dev-base as conda-pyenv
65+ ARG PYTHON_MAJOR_VERSION=3
66+ ARG PYTHON_MINOR_VERSION=8
67+ ENV PYTHON_MINOR_VERSION=${PYTHON_MINOR_VERSION}
68+ ENV PYTHON_VERSION=${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}
69+ RUN if [[ ${PYTHON_MINOR_VERSION} -gt 7 ]]; then \
70+ curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
7171 chmod +x ~/miniconda.sh && \
7272 ~/miniconda.sh -b -p /opt/conda && \
7373 rm ~/miniconda.sh && \
7474 /opt/conda/bin/conda install -y python=${PYTHON_VERSION} mkl mkl-include conda-build pyyaml numpy ipython && \
7575 /opt/conda/bin/conda install -y -c conda-forge libpython-static=${PYTHON_VERSION} && \
7676 /opt/conda/bin/conda install -y pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch-nightly && \
77- /opt/conda/bin/conda clean -ya
78-
77+ /opt/conda/bin/conda clean -ya; \
78+ else \
79+ pip3 install virtualenv && \
80+ git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \
81+ export CFLAGS="-fPIC -g" && \
82+ ~/.pyenv/bin/pyenv install --force 3.7.10 && \
83+ virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy; \
84+ fi
7985
8086# Build/Install pytorch with post-cxx11 ABI
81- FROM conda as build
87+ FROM conda-pyenv as build
8288WORKDIR /opt/multipy/multipy/runtime/third-party/pytorch
83- COPY --from=conda /opt/conda /opt/conda
89+ COPY --from=conda-pyenv /opt/conda* /opt/conda
8490COPY --from=submodule-update /opt/multipy /opt/multipy
8591
8692WORKDIR /opt/multipy
8793
8894# Build Multipy
8995RUN mkdir multipy/runtime/build && \
90- cd multipy/runtime/build && \
91- cmake .. && \
92- cmake --build . --config Release && \
93- cmake --install . --prefix "."
96+ cd multipy/runtime/build && \
97+ if [[ ${PYTHON_MINOR_VERSION} -lt 8 ]]; then \
98+ source ~/venvs/multipy/bin/activate && \
99+ pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu113 && \
100+ cmake -DLEGACY_PYTHON_PRE_3_8=ON ..; \
101+ else \
102+ cmake -DLEGACY_PYTHON_PRE_3_8=OFF ..; \
103+ fi && \
104+ cmake --build . --config Release && \
105+ cmake --install . --prefix "." && \
106+ cd ../example && python generate_examples.py
94107
95- RUN cd multipy/runtime/example && python generate_examples.py
96108ENV PYTHONPATH=. LIBTEST_DEPLOY_LIB=multipy/runtime/build/libtest_deploy_lib.so
97109
98110RUN mkdir /opt/dist && cp -r multipy/runtime/build/dist/* /opt/dist/
0 commit comments