@@ -2,6 +2,8 @@ ARG BASE_IMAGE=nvidia/cuda:11.3.1-devel-ubuntu18.04
2
2
3
3
FROM ${BASE_IMAGE} as dev-base
4
4
5
+ SHELL ["/bin/bash" , "-c" ]
6
+
5
7
# Install system dependencies
6
8
RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
7
9
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 \
39
41
apt-transport-https \
40
42
ca-certificates \
41
43
gnupg \
42
- software-properties-common && \
44
+ software-properties-common \
45
+ python-pip \
46
+ python3-pip && \
43
47
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \
44
48
apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \
45
49
echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \
@@ -56,43 +60,51 @@ WORKDIR /opt/multipy
56
60
COPY . .
57
61
RUN git submodule update --init --recursive --jobs 0
58
62
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 && \
71
71
chmod +x ~/miniconda.sh && \
72
72
~/miniconda.sh -b -p /opt/conda && \
73
73
rm ~/miniconda.sh && \
74
74
/opt/conda/bin/conda install -y python=${PYTHON_VERSION} mkl mkl-include conda-build pyyaml numpy ipython && \
75
75
/opt/conda/bin/conda install -y -c conda-forge libpython-static=${PYTHON_VERSION} && \
76
76
/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
79
85
80
86
# Build/Install pytorch with post-cxx11 ABI
81
- FROM conda as build
87
+ FROM conda-pyenv as build
82
88
WORKDIR /opt/multipy/multipy/runtime/third-party/pytorch
83
- COPY --from=conda /opt/conda /opt/conda
89
+ COPY --from=conda-pyenv /opt/conda* /opt/conda
84
90
COPY --from=submodule-update /opt/multipy /opt/multipy
85
91
86
92
WORKDIR /opt/multipy
87
93
88
94
# Build Multipy
89
95
RUN 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
94
107
95
- RUN cd multipy/runtime/example && python generate_examples.py
96
108
ENV PYTHONPATH=. LIBTEST_DEPLOY_LIB=multipy/runtime/build/libtest_deploy_lib.so
97
109
98
110
RUN mkdir /opt/dist && cp -r multipy/runtime/build/dist/* /opt/dist/
0 commit comments