What is the recommended way to install Azure ML R SDK in a Docker container and deploy as a Web Service? I am trying to deploy an Azure ML Web Service Endpoint in an Azure Container Instance. I have made a custom Docker image and registered it as an Environment in Azure ML Workspace. I have a minimal inference script as follows:
The deployment is successful and the container starts up without errors. However, when I call the Web Service endpoint, the following error occurs:
home/dockeruser/miniconda/lib/python3.7/site-packages/rpy2/rinterface/__init__.py:146: RRuntimeWarning: No non-system installation of Python could be found.
Would you like to download and install Miniconda?
Miniconda is an open source environment management system for Python.
See https://docs.conda.io/en/latest/miniconda.html for more details.
warnings.warn(x, RRuntimeWarning)
Would you like to install Miniconda? [Y/n]:
Traceback (most recent call last):
File "/home/dockeruser/miniconda/lib/python3.7/site-packages/rpy2/rinterface/__init__.py", line 158, in consoleRead
text = input(prompt)
EOFError
:
EOF when reading a line
/home/dockeruser/miniconda/lib/python3.7/site-packages/rpy2/rinterface/__init__.py:146: RRuntimeWarning: Error: missing value where TRUE/FALSE needed
A similar error was reported in Azure ML Notebook Compute Instances, see issue #361. The error was fixed there by changing the Notebook environment. How can I circumvent this issue in AML Web Service container, where there is no way to give input?
Note that the error is thrown when I call the functions service_principal_authentication and get_workspace. If I remove those commands and leave library(azuremlsdk), the script is executed successfully and response is returned as expected.
This is my full Dockerfile:
FROM ubuntu
ARG PYTHON_VERSION=3.7
ARG CONDA_VERSION=4.8.3
ARG AZUREML_SDK_VERSION=1.13.0
ARG DEBIAN_FRONTEND=noninteractive
USER root:root
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
RUN apt-get update --fix-missing && \
apt-get upgrade -y && \
apt-get install -y bzip2 wget curl gcc && \
apt-get install -y fuse
# Azure CLI
RUN apt-get install -y apt-transport-https lsb-release gnupg
RUN CLI_REPO="$(lsb_release -cs)" && \
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.asc.gpg && \
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ ${CLI_REPO} main" > /etc/apt/sources.list.d/azure-cli.list && \
apt-get update && \
apt-get install -y azure-cli
# Clean OS installation files
RUN apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
# Docker user
RUN useradd --create-home dockeruser
WORKDIR /home/dockeruser
USER dockeruser
# Miniconda
ENV CONDA_PATH=/home/dockeruser/miniconda
ENV PATH="${PATH}:${CONDA_PATH}/bin/"
RUN wget -qO /home/dockeruser/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-py37_$CONDA_VERSION-Linux-x86_64.sh && \
bash /home/dockeruser/miniconda.sh -b -p $CONDA_PATH && \
rm /home/dockeruser/miniconda.sh
RUN conda init bash
# Essential Azure ML Service & R dependencies from conda
RUN conda install -qy conda=${CONDA_VERSION} python=${PYTHON_VERSION} && \
conda install --channel r -qy conda=${CONDA_VERSION} r-essentials rpy2 r-reticulate r-devtools r-testthat && \
conda clean -aqy
RUN pip install azureml-defaults==${AZUREML_SDK_VERSION} && \
pip install azureml-dataprep[pandas,fuse] && \
pip install inference-schema
# Clean conda installation files
RUN rm -rf $CONDA_PATH/pkgs && \
find $CONDA_PATH -type d -name __pycache__ -prune | xargs rm -rf
# Azure ML Service dependencies
ENV TAR=/bin/tar
RUN R -e 'remotes::install_github("https://github.com/Azure/azureml-sdk-for-r", build_vignettes = TRUE)'
RUN R -e 'azuremlsdk::install_azureml()'
As a side note, I am also seeing errors when installing Azure ML R SDK in Docker. The SDK requires the dependency httpuv, which produces thousands of lines of errors like warning: 'template<class> class std::auto_ptr' is deprecated. This is the beginning of the error messages:
In file included from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/bind/mem_fn.hpp:25:0,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/mem_fn.hpp:22,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/bind/bind.hpp:26,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/bind.hpp:22,
from callback_registry.cpp:1:
/home/dockeruser/miniconda/lib/R/library/BH/include/boost/get_pointer.hpp:48:40: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
template<class T> T * get_pointer(std::auto_ptr<T> const& p)
^~~~~~~~
In file included from /home/dockeruser/miniconda/x86_64-conda_cos6-linux-gnu/include/c++/7.3.0/memory:80:0,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/config/no_tr1/memory.hpp:21,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/get_pointer.hpp:14,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/bind/mem_fn.hpp:25,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/mem_fn.hpp:22,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/bind/bind.hpp:26,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/bind.hpp:22,
from callback_registry.cpp:1:
/home/dockeruser/miniconda/x86_64-conda_cos6-linux-gnu/include/c++/7.3.0/bits/unique_ptr.h:51:28: note: declared here
template<typename> class auto_ptr;
^~~~~~~~
In file included from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp:28:0,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/shared_ptr.hpp:17,
from callback_registry.cpp:2:
/home/dockeruser/miniconda/lib/R/library/BH/include/boost/smart_ptr/detail/shared_count.hpp:356:33: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
explicit shared_count( std::auto_ptr<Y> & r ): pi_( new sp_counted_impl_p<Y>( r.get() ) )
^~~~~~~~
In file included from /home/dockeruser/miniconda/x86_64-conda_cos6-linux-gnu/include/c++/7.3.0/memory:80:0,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/config/no_tr1/memory.hpp:21,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/get_pointer.hpp:14,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/bind/mem_fn.hpp:25,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/mem_fn.hpp:22,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/bind/bind.hpp:26,
from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/bind.hpp:22,
from callback_registry.cpp:1:
/home/dockeruser/miniconda/x86_64-conda_cos6-linux-gnu/include/c++/7.3.0/bits/unique_ptr.h:51:28: note: declared here
template<typename> class auto_ptr;
^~~~~~~~
In file included from /home/dockeruser/miniconda/lib/R/library/BH/include/boost/shared_ptr.hpp:17:0,
from callback_registry.cpp:2:
/home/dockeruser/miniconda/lib/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp:256:65: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R >
It doesn't matter if I install the CRAN version (1.10.0) or Github version (1.13.0) of the SDK, these errors always persist.
What is the recommended way to install Azure ML R SDK in a Docker container and deploy as a Web Service? I am trying to deploy an Azure ML Web Service Endpoint in an Azure Container Instance. I have made a custom Docker image and registered it as an Environment in Azure ML Workspace. I have a minimal inference script as follows:
The deployment is successful and the container starts up without errors. However, when I call the Web Service endpoint, the following error occurs:
A similar error was reported in Azure ML Notebook Compute Instances, see issue #361. The error was fixed there by changing the Notebook environment. How can I circumvent this issue in AML Web Service container, where there is no way to give input?
Note that the error is thrown when I call the functions
service_principal_authentication
andget_workspace
. If I remove those commands and leavelibrary(azuremlsdk)
, the script is executed successfully and response is returned as expected.This is my full Dockerfile:
As a side note, I am also seeing errors when installing Azure ML R SDK in Docker. The SDK requires the dependency
httpuv
, which produces thousands of lines of errors likewarning: 'template<class> class std::auto_ptr' is deprecated
. This is the beginning of the error messages:It doesn't matter if I install the CRAN version (1.10.0) or Github version (1.13.0) of the SDK, these errors always persist.