FROM ubuntu:16.04 LABEL maintainer="Amazon AI" LABEL dlc_major_version="1" ARG PYTHON=python3 ARG PIP=pip3 ARG PYTHON_VERSION=3.7.10 ARG MX_URL=https://aws-mx-pypi.s3-us-west-2.amazonaws.com/1.8.0/aws_mx-1.8.0-py2.py3-none-manylinux2014_x86_64.whl # The smdebug pipeline relies for following format to perform string replace and trigger DLC pipeline for validating # the nightly builds. Therefore, while updating the smdebug version, please ensure that the format is not disturbed. ARG SMDEBUG_VERSION=0.9.4 ARG OPENSSL_VERSION=1.1.1l ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib" \ PYTHONIOENCODING=UTF-8 \ LANG=C.UTF-8 \ LC_ALL=C.UTF-8 \ SAGEMAKER_TRAINING_MODULE=sagemaker_mxnet_container.training:main \ DGLBACKEND=mxnet RUN apt-get update \ && apt-get install -y --no-install-recommends \ software-properties-common \ build-essential \ ca-certificates \ curl \ emacs \ git \ libopencv-dev \ openssh-client \ openssh-server \ vim \ wget \ unzip \ zlib1g-dev \ libreadline-gplv2-dev \ libncursesw5-dev \ libssl-dev \ libsqlite3-dev \ libgdbm-dev \ libc6-dev \ libbz2-dev \ tk-dev \ libffi-dev \ cmake \ # Install dependent library for OpenCV libgtk2.0-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* ## This section is for allowing the automatic updates of vulnerable packages. COPY apt-upgrade-list.txt /tmp/apt-upgrade-list.txt RUN apt-get update \ && apt-get install --only-upgrade $(cat /tmp/apt-upgrade-list.txt) \ && rm -rf /tmp/apt-upgrade-list.txt ########################################################################### # Horovod dependencies ########################################################################### # Install Open MPI RUN mkdir /tmp/openmpi \ && cd /tmp/openmpi \ && wget -q https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.1.tar.gz \ && tar zxf openmpi-4.0.1.tar.gz \ && cd openmpi-4.0.1 \ && ./configure --enable-orterun-prefix-by-default \ && make -j $(nproc) all \ && make install \ && ldconfig \ && cd /tmp && rm -rf /tmp/openmpi # Create a wrapper for OpenMPI to allow running as root by default RUN mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real \ && echo '#!/bin/bash' > /usr/local/bin/mpirun \ && echo 'mpirun.real --allow-run-as-root "$@"' >> /usr/local/bin/mpirun \ && chmod a+x /usr/local/bin/mpirun \ && echo "hwloc_base_binding_policy = none" >> /usr/local/etc/openmpi-mca-params.conf \ && echo "rmaps_base_mapping_policy = slot" >> /usr/local/etc/openmpi-mca-params.conf ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH ENV PATH=/usr/local/bin:$PATH # install OpenSSL RUN wget -q https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz \ && tar -xzf openssl-${OPENSSL_VERSION}.tar.gz \ && cd openssl-${OPENSSL_VERSION} \ && ./config && make -j $(nproc) && make install \ && ldconfig \ && cd .. && rm -rf openssl-* \ && rmdir /usr/local/ssl/certs \ && ln -s /etc/ssl/certs /usr/local/ssl/certs # install Python RUN wget -q https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz \ && tar -xzf Python-$PYTHON_VERSION.tgz \ && cd Python-$PYTHON_VERSION \ && ./configure --enable-shared --prefix=/usr/local \ && make -j $(nproc) && make install \ && cd .. && rm -rf ../Python-$PYTHON_VERSION* \ && ln -s /usr/local/bin/pip3 /usr/bin/pip \ && ln -s /usr/local/bin/$PYTHON /usr/local/bin/python \ && ${PIP} --no-cache-dir install --upgrade \ pip \ setuptools WORKDIR / RUN ${PIP} install --no-cache --upgrade \ keras-mxnet==2.2.4.2 \ "h5py<3" \ "onnx>=1.7.0,<1.9.0" \ "numpy>1.16.0,<=1.19.1" \ pandas \ Pillow \ "requests>=2.18.4,<=2.22.0" \ scikit-learn \ dgl==0.4.* \ "scipy>=1.2.2,<=1.4.1" \ gluonnlp==0.10.0 \ gluoncv==0.8.0 \ # Putting a cap in versions number to avoid potential issues with a new major version "urllib3>=1.25.10,<1.26.0" \ # python-dateutil==2.8.0 to satisfy botocore associated with latest awscli python-dateutil==2.8.0 \ tqdm==4.39.0 \ sagemaker-experiments==0.* \ # install PyYAML>=5.4,<5.5 to avoid conflict with latest awscli "PyYAML>=5.4,<5.5" \ mpi4py==3.0.2 \ sagemaker-mxnet-training \ ${MX_URL} \ smdebug==${SMDEBUG_VERSION} \ sagemaker \ awscli \ smclarify # Install extra packages # numba 0.54 only works with numpy>=1.20. See https://github.com/numba/numba/issues/7339 RUN pip install --no-cache-dir -U \ "bokeh>=2.3,<3" \ "imageio>=2.9,<3" \ "opencv-python>=4.3,<5" \ "plotly>=5.1,<6" \ "seaborn>=0.11,<1" \ "numba<0.54" \ "shap>=0.39,<1" # Install Horovod RUN ${PIP} install --no-cache-dir horovod==0.19.5 # Allow OpenSSH to talk to containers without asking for confirmation RUN cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new \ && echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new \ && mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config # OpenSHH config for MPI communication RUN mkdir -p /var/run/sshd && \ sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd RUN rm -rf /root/.ssh/ && \ mkdir -p /root/.ssh/ && \ ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa && \ cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys \ && printf "Host *\n StrictHostKeyChecking no\n" >> /root/.ssh/config # "channels first" is recommended for keras-mxnet # https://github.com/awslabs/keras-apache-mxnet/blob/master/docs/mxnet_backend/performance_guide.md#channels-first-image-data-format-for-cnn RUN mkdir /root/.keras \ && echo '{"image_data_format": "channels_first"}' > /root/.keras/keras.json # This is here to make our installed version of OpenCV work. # https://stackoverflow.com/questions/29274638/opencv-libdc1394-error-failed-to-initialize-libdc1394 # TODO: Should we be installing OpenCV in our image like this? Is there another way we can fix this? RUN ln -s /dev/null /dev/raw1394 COPY deep_learning_container.py /usr/local/bin/deep_learning_container.py RUN chmod +x /usr/local/bin/deep_learning_container.py RUN HOME_DIR=/root \ && curl -o ${HOME_DIR}/oss_compliance.zip https://aws-dlinfra-utilities.s3.amazonaws.com/oss_compliance.zip \ && unzip ${HOME_DIR}/oss_compliance.zip -d ${HOME_DIR}/ \ && cp ${HOME_DIR}/oss_compliance/test/testOSSCompliance /usr/local/bin/testOSSCompliance \ && chmod +x /usr/local/bin/testOSSCompliance \ && chmod +x ${HOME_DIR}/oss_compliance/generate_oss_compliance.sh \ && ${HOME_DIR}/oss_compliance/generate_oss_compliance.sh ${HOME_DIR} ${PYTHON} \ && rm -rf ${HOME_DIR}/oss_compliance* RUN curl -o /license.txt https://aws-dlc-licenses.s3.amazonaws.com/aws-mx-1.8.0/license.txt CMD ["/bin/bash"]