Skip to content

Commit 49e4356

Browse files
Nikhil Raverkarawsbmillare
Nikhil Raverkar
authored andcommitted
upgrading sklearn to 1.0.2
1 parent 51cfe91 commit 49e4356

File tree

3 files changed

+173
-1
lines changed

3 files changed

+173
-1
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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

docker/1.0-1/final/Dockerfile.cpu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ ENV TEMP=/home/model-server/tmp
5454

5555
# Required label for multi-model loading
5656
LABEL com.amazonaws.sagemaker.capabilities.multi-models=true
57-
57+
LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM sklearn-base:1.0-1-arm64-cpu-py3
2+
ENV SAGEMAKER_SKLEARN_VERSION 1.0-1
3+
4+
LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true
5+
6+
COPY requirements.txt /requirements.txt
7+
RUN python -m pip install -r /requirements.txt && \
8+
rm /requirements.txt
9+
10+
COPY dist/sagemaker_sklearn_container-2.0-py3-none-any.whl /sagemaker_sklearn_container-2.0-py3-none-any.whl
11+
# # https://github.com/googleapis/google-cloud-python/issues/6647
12+
RUN rm -rf /miniconda3/lib/python3.7/site-packages/numpy-1.19.4.dist-info && \
13+
pip install --no-cache /sagemaker_sklearn_container-2.0-py3-none-any.whl && \
14+
rm /sagemaker_sklearn_container-2.0-py3-none-any.whl
15+
16+
ENV SAGEMAKER_TRAINING_MODULE sagemaker_sklearn_container.training:main
17+
ENV SAGEMAKER_SERVING_MODULE sagemaker_sklearn_container.serving:main
18+
19+
#######
20+
# MMS #
21+
#######
22+
# Create MMS user directory
23+
RUN useradd -m model-server
24+
RUN mkdir -p /home/model-server/tmp
25+
RUN chown -R model-server /home/model-server
26+
27+
# Copy MMS configs
28+
COPY docker/$SAGEMAKER_SKLEARN_VERSION/resources/mms/config.properties.tmp /home/model-server
29+
ENV SKLEARN_MMS_CONFIG=/home/model-server/config.properties
30+
31+
# Copy execution parameters endpoint plugin for MMS
32+
RUN mkdir -p /tmp/plugins
33+
COPY docker/$SAGEMAKER_SKLEARN_VERSION/resources/mms/endpoints-1.0.jar /tmp/plugins
34+
RUN chmod +x /tmp/plugins/endpoints-1.0.jar
35+
36+
# Create directory for models
37+
RUN mkdir -p /opt/ml/models
38+
RUN chmod +rwx /opt/ml/models
39+
40+
#####################
41+
# Required ENV vars #
42+
#####################
43+
# Set SageMaker training environment variables
44+
ENV SM_INPUT /opt/ml/input
45+
ENV SM_INPUT_TRAINING_CONFIG_FILE $SM_INPUT/config/hyperparameters.json
46+
ENV SM_INPUT_DATA_CONFIG_FILE $SM_INPUT/config/inputdataconfig.json
47+
ENV SM_CHECKPOINT_CONFIG_FILE $SM_INPUT/config/checkpointconfig.json
48+
49+
# Set SageMaker serving environment variables
50+
ENV SM_MODEL_DIR /opt/ml/model
51+
52+
#EXPOSE 8080
53+
ENV TEMP=/home/model-server/tmp
54+
55+
# Required label for multi-model loading
56+
LABEL com.amazonaws.sagemaker.capabilities.multi-models=true
57+
LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true

0 commit comments

Comments
 (0)