amazon-sagemaker-examples icon indicating copy to clipboard operation
amazon-sagemaker-examples copied to clipboard

[bug] Docker File not building in scikit_bring_your_own example

Open ElianoMarques opened this issue 3 years ago • 4 comments

Hi, I'm building an example following this: https://github.com/aws/amazon-sagemaker-examples/blob/main/advanced_functionality/scikit_bring_your_own/container/Dockerfile

When I try to run build this docker Image I get the following error:

 => ERROR [5/7] RUN pip --no-cache-dir install numpy==1.16.2 scipy==1.2.1 scikit-learn==0.20.2 pandas flask gunicorn                                                                                             8.1s 
------                                                                                                                                                                                                                
 > [5/7] RUN pip --no-cache-dir install numpy==1.16.2 scipy==1.2.1 scikit-learn==0.20.2 pandas flask gunicorn:                                                                                                        
#9 0.834 Collecting numpy==1.16.2                                                                                                                                                                                     
#9 1.662   Downloading https://files.pythonhosted.org/packages/cf/8d/6345b4f32b37945fedc1e027e83970005fc9c699068d2f566b82826515f2/numpy-1.16.2.zip (5.1MB)                                                            
#9 2.613 Collecting scipy==1.2.1                                                                                                                                                                                      
#9 2.906   Downloading https://files.pythonhosted.org/packages/a9/b4/5598a706697d1e2929eaf7fe68898ef4bea76e4950b9efbe1ef396b8813a/scipy-1.2.1.tar.gz (23.1MB)
#9 7.953     Complete output from command python setup.py egg_info:
#9 7.953     Traceback (most recent call last):
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 154, in save_modules
#9 7.953         yield saved
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 195, in setup_context
#9 7.953         yield
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 250, in run_setup
#9 7.953         _execfile(setup_script, ns)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 45, in _execfile
#9 7.953         exec(code, globals, locals)
#9 7.953       File "/tmp/easy_install-kl99y_jm/numpy-1.22.2/setup.py", line 34, in <module>
#9 7.953         else:
#9 7.953     RuntimeError: Python version >= 3.8 required.
#9 7.953     
#9 7.953     During handling of the above exception, another exception occurred:
#9 7.953     
#9 7.953     Traceback (most recent call last):
#9 7.953       File "<string>", line 1, in <module>
#9 7.953       File "/tmp/pip-build-kqrfrkdu/scipy/setup.py", line 492, in <module>
#9 7.953         setup_package()
#9 7.953       File "/tmp/pip-build-kqrfrkdu/scipy/setup.py", line 488, in setup_package
#9 7.953         setup(**metadata)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 128, in setup
#9 7.953         _install_setup_requires(attrs)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 123, in _install_setup_requires
#9 7.953         dist.fetch_build_eggs(dist.setup_requires)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 513, in fetch_build_eggs
#9 7.953         replace_conflicting=True,
#9 7.953       File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 774, in resolve
#9 7.953         replace_conflicting=replace_conflicting
#9 7.953       File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1057, in best_match
#9 7.953         return self.obtain(req, installer)
#9 7.953       File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1069, in obtain
#9 7.953         return installer(requirement)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 580, in fetch_build_egg
#9 7.953         return cmd.easy_install(req)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 698, in easy_install
#9 7.953         return self.install_item(spec, dist.location, tmpdir, deps)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 724, in install_item
#9 7.953         dists = self.install_eggs(spec, download, tmpdir)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 909, in install_eggs
#9 7.953         return self.build_and_install(setup_script, setup_base)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1177, in build_and_install
#9 7.953         self.run_setup(setup_script, setup_base, args)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1163, in run_setup
#9 7.953         run_setup(setup_script, args)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 253, in run_setup
#9 7.953         raise
#9 7.953       File "/usr/lib/python3.6/contextlib.py", line 99, in __exit__
#9 7.953         self.gen.throw(type, value, traceback)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 195, in setup_context
#9 7.953         yield
#9 7.953       File "/usr/lib/python3.6/contextlib.py", line 99, in __exit__
#9 7.953         self.gen.throw(type, value, traceback)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 166, in save_modules
#9 7.953         saved_exc.resume()
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 141, in resume
#9 7.953         six.reraise(type, exc, self._tb)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/_vendor/six.py", line 685, in reraise
#9 7.953         raise value.with_traceback(tb)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 154, in save_modules
#9 7.953         yield saved
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 195, in setup_context
#9 7.953         yield
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 250, in run_setup
#9 7.953         _execfile(setup_script, ns)
#9 7.953       File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 45, in _execfile
#9 7.953         exec(code, globals, locals)
#9 7.953       File "/tmp/easy_install-kl99y_jm/numpy-1.22.2/setup.py", line 34, in <module>
#9 7.953         else:
#9 7.953     RuntimeError: Python version >= 3.8 required.
#9 7.953     
#9 7.953     ----------------------------------------
#9 8.044 Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-kqrfrkdu/scipy/
------
executor failed running [/bin/sh -c pip --no-cache-dir install numpy==1.16.2 scipy==1.2.1 scikit-learn==0.20.2 pandas flask gunicorn]: exit code: 1

Seems there is a conflict with scipy installation, not recognising numpy. This is actually something that you have written in the dockerfile as you overcome but seems not to be working.

# There's substantial overlap between scipy and numpy that we eliminate by
# linking them together. Likewise, pip leaves the install caches populated which uses
# a significant amount of space. These optimizations save a fair amount of space in the
# image, which reduces start up time.
RUN pip --no-cache-dir install numpy==1.16.2 scipy==1.2.1 scikit-learn==0.20.2 pandas flask gunicorn

Could this dockerfile be updated?

ElianoMarques avatar Feb 17 '22 22:02 ElianoMarques

still true, 7 months later. Thanks for 👀 !

JanetMatsen avatar Sep 22 '22 11:09 JanetMatsen

still true, any updates in the Dockerfile?

Lulu20220 avatar Oct 27 '22 05:10 Lulu20220

still true

stevehs17 avatar Oct 25 '23 22:10 stevehs17

I was able to build the image by changing the Docker file in the repository to look like this:

FROM ubuntu:22.04

RUN apt-get -y update && apt-get install -y --no-install-recommends \
         wget \
         python3-pip \
         python3-setuptools \
         nginx \
         ca-certificates \
    && rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN pip --no-cache-dir install numpy scipy scikit-learn pandas flask gunicorn

ENV PYTHONUNBUFFERED=TRUE
ENV PYTHONDONTWRITEBYTECODE=TRUE
ENV PATH="/opt/program:${PATH}"

COPY decision_trees /opt/program
WORKDIR /opt/program

Apparently, the specific Python 3 version that gets installed using the apt-get command above is determined by the specific version of the Ubuntu OS that's installed. With Ubuntu 20.04 installed, I ended up with Python 3.10.

stevehs17 avatar Oct 26 '23 01:10 stevehs17