|
| 1 | +ARG UBUNTU_VERSION=18.04 |
| 2 | +ARG UBUNTU_IMAGE_DIGEST=646942475da61b4ce9cc5b3fadb42642ea90e5d0de46111458e100ff2c7031e6 |
| 3 | + |
| 4 | +FROM ubuntu:${UBUNTU_VERSION}@sha256:${UBUNTU_IMAGE_DIGEST} |
| 5 | + |
| 6 | +ARG MINICONDA_VERSION=4.9.2 # Upgraded version |
| 7 | +ARG CONDA_PY_VERSION=39 |
| 8 | +ARG CONDA_PKG_VERSION=4.10.1 |
| 9 | +ARG PYTHON_VERSION=3.7.10 |
| 10 | +ARG PYARROW_VERSION=1.0 |
| 11 | +ARG MLIO_VERSION=arch-agnostic |
| 12 | + |
| 13 | +# Install python and other scikit-learn runtime dependencies |
| 14 | +# Dependency list from http://scikit-learn.org/stable/developers/advanced_installation.html#installing-build-dependencies |
| 15 | +RUN apt-get update && \ |
| 16 | + apt-get -y upgrade && \ |
| 17 | + apt-get -y install --no-install-recommends \ |
| 18 | + build-essential \ |
| 19 | + curl \ |
| 20 | + git \ |
| 21 | + jq \ |
| 22 | + libatlas-base-dev \ |
| 23 | + nginx \ |
| 24 | + openjdk-8-jdk-headless \ |
| 25 | + unzip \ |
| 26 | + wget \ |
| 27 | + && \ |
| 28 | + |
| 29 | + apt-get -y install --no-install-recommends \ |
| 30 | + apt-transport-https \ |
| 31 | + ca-certificates \ |
| 32 | + gnupg \ |
| 33 | + software-properties-common \ |
| 34 | + autoconf \ |
| 35 | + automake \ |
| 36 | + build-essential \ |
| 37 | + libssl-dev \ |
| 38 | + && \ |
| 39 | + # MLIO build dependencies |
| 40 | + # Official Ubuntu APT repositories do not contain an up-to-date version of CMake required to build MLIO. |
| 41 | + # Kitware contains the latest version of CMake. |
| 42 | + wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | \ |
| 43 | + gpg --dearmor - | \ |
| 44 | + tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \ |
| 45 | + apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \ |
| 46 | + wget https://cmake.org/files/v3.18/cmake-3.18.4.tar.gz && \ |
| 47 | + tar -xzvf cmake-3.18.4.tar.gz && \ |
| 48 | + cd cmake-3.18.4 && \ |
| 49 | + ./configure && \ |
| 50 | + make -j$(nproc) && \ |
| 51 | + make install && \ |
| 52 | + apt-get update && \ |
| 53 | + apt-get install -y --no-install-recommends \ |
| 54 | + |
| 55 | + cmake-data=3.18.4-0kitware1 \ |
| 56 | + doxygen \ |
| 57 | + kitware-archive-keyring \ |
| 58 | + libcurl4-openssl-dev \ |
| 59 | + libtool \ |
| 60 | + ninja-build \ |
| 61 | + python3-dev \ |
| 62 | + python3-distutils \ |
| 63 | + python3-pip \ |
| 64 | + zlib1g-dev \ |
| 65 | + && \ |
| 66 | + rm /etc/apt/trusted.gpg.d/kitware.gpg && \ |
| 67 | + rm -rf /var/lib/apt/lists/* |
| 68 | + |
| 69 | +RUN cd /tmp && \ |
| 70 | + curl -L --output /tmp/Miniconda3.sh https://repo.anaconda.com/miniconda/Miniconda3-py${CONDA_PY_VERSION}_${MINICONDA_VERSION}-Linux-aarch64.sh && \ |
| 71 | + bash /tmp/Miniconda3.sh -bfp /miniconda3 && \ |
| 72 | + rm /tmp/Miniconda3.sh |
| 73 | + |
| 74 | +ENV PATH=/miniconda3/bin:${PATH} |
| 75 | + |
| 76 | +# Install MLIO with Apache Arrow integration |
| 77 | +# We could install mlio-py from conda, but it comes with extra support such as image reader that increases image size |
| 78 | +# which increases training time. We build from source to minimize the image size. |
| 79 | +RUN echo "conda ${CONDA_PKG_VERSION}" >> /miniconda3/conda-meta/pinned && \ |
| 80 | + # Conda configuration see https://conda.io/projects/conda/en/latest/configuration.html |
| 81 | + conda config --system --set auto_update_conda false && \ |
| 82 | + conda config --system --set show_channel_urls true && \ |
| 83 | + echo "python ${PYTHON_VERSION}.*" >> /miniconda3/conda-meta/pinned && \ |
| 84 | + conda install -c conda-forge python=${PYTHON_VERSION} && \ |
| 85 | + conda install conda=${CONDA_PKG_VERSION} && \ |
| 86 | + conda update -y conda && \ |
| 87 | + conda install -c conda-forge pyarrow=${PYARROW_VERSION} && \ |
| 88 | + cd /tmp && \ |
| 89 | + git clone --branch ${MLIO_VERSION} https://github.com/awslabs/ml-io.git mlio && \ |
| 90 | + cd mlio && \ |
| 91 | + build-tools/build-dependency build/third-party all && \ |
| 92 | + mkdir -p build/release && \ |
| 93 | + cd build/release && \ |
| 94 | + cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PREFIX_PATH="$(pwd)/../third-party" ../.. && \ |
| 95 | + cmake --build . && \ |
| 96 | + cmake --build . --target install && \ |
| 97 | + cmake -DMLIO_INCLUDE_PYTHON_EXTENSION=ON -DMLIO_INCLUDE_ARROW_INTEGRATION=ON ../.. && \ |
| 98 | + cmake --build . --target mlio-py && \ |
| 99 | + cmake --build . --target mlio-arrow && \ |
| 100 | + cd ../../src/mlio-py && \ |
| 101 | + python3 setup.py bdist_wheel && \ |
| 102 | + python3 -m pip install --upgrade pip && \ |
| 103 | + python3 -m pip install dist/*.whl && \ |
| 104 | + cp -r /tmp/mlio/build/third-party/lib/libtbb* /usr/local/lib/ && \ |
| 105 | + ldconfig && \ |
| 106 | + rm -rf /tmp/mlio |
| 107 | + |
| 108 | +# Python won’t try to write .pyc or .pyo files on the import of source modules |
| 109 | +# Force stdin, stdout and stderr to be totally unbuffered. Good for logging |
| 110 | +ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 PYTHONIOENCODING=UTF-8 LANG=C.UTF-8 LC_ALL=C.UTF-8 |
| 111 | + |
| 112 | +# Install Scikit-Learn |
| 113 | +# Scikit-learn 0.20 was the last version to support Python 2.7 and Python 3.4. |
| 114 | +# Scikit-learn now requires Python 3.6 or newer. |
| 115 | + RUN python -m pip install --no-cache -I scikit-learn==1.0.2 |
0 commit comments