Я следую этому руководству , чтобы создать образ Docker для приложения для колб.Приложение зависит от Torch / PyTorch.Таким образом, мой requirements.txt
файл выглядит следующим образом.
flask
flask-cors
pytorch
torchvision
pandas
Мой Dockerfile выглядит следующим образом:
FROM ubuntu:latest
LABEL My Company "info@mycompany.com"
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
COPY . /app
WORKDIR /app
RUN pip install -vvv --no-cache-dir -r requirements.txt
ENTRYPOINT ["python3"]
CMD ["app.py"]
Когда я набираю команду docker build -t flask-sample-one:latest .
, я получаюследующее сообщение об ошибке (которое происходит, когда pip пытается установить факел) на моем Mac.
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 353, in run
wb.build(autobuilding=True)
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 620, in _prepare_file
session=self.session, hashes=hashes)
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 821, in unpack_url
hashes=hashes
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 659, in unpack_http_url
hashes)
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 882, in _download_http_url
_download_url(resp, link, content_file, hashes)
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 603, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File "/usr/lib/python2.7/dist-packages/pip/utils/hashes.py", line 46, in check_against_chunks
for chunk in chunks:
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 571, in written_chunks
for chunk in chunks:
File "/usr/lib/python2.7/dist-packages/pip/utils/ui.py", line 139, in iter
for x in it:
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 560, in resp_read
decode_content=False):
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 436, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 384, in read
data = self._fp.read(amt)
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py", line 63, in read
self._close()
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py", line 50, in _close
self.__callback(self.__buf.getvalue())
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/controller.py", line 275, in cache_response
self.serializer.dumps(request, response, body=body),
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/serialize.py", line 55, in dumps
"body": _b64_encode_bytes(body),
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/serialize.py", line 12, in _b64_encode_bytes
return base64.b64encode(b).decode("ascii")
MemoryError
The command '/bin/sh -c pip install -vvv -r requirements.txt' returned a non-zero code: 2
Я не уверен, откуда взялся MemoryError
.Я попытался создать образ докера на Macbook Pro с 16 ГБ оперативной памяти.Любые идеи о том, что происходит или как создать образ докера с Python?
В экземпляре AWS EC2 я получаю следующую ошибку:
Running setup.py install for pytorch: started
Running command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-SeBh33/pytorch/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-5jxyuS-record/install-record.txt --single-version-externally-managed --compile
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-SeBh33/pytorch/setup.py", line 13, in
raise Exception(message)
Exception: You should install pytorch from http://pytorch.org
Running setup.py install for pytorch: finished with status 'error'
Cleaning up...
Removing source in /tmp/pip-build-SeBh33/pytorch
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-SeBh33/pytorch/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-5jxyuS-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-SeBh33/pytorch/
Exception information:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 360, in run
prefix=options.prefix_path,
File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 878, in install
spinner=spinner,
File "/usr/lib/python2.7/dist-packages/pip/utils/__init__.py", line 725, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-SeBh33/pytorch/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-5jxyuS-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-SeBh33/pytorch/
The command '/bin/sh -c pip install -vvv --no-cache-dir -r requirements.txt' returned a non-zero code: 1
Есть идеи о том, что происходит?Я просто пытаюсь создать образ докера с этими несколькими зависимостями, чтобы я мог обслуживать модель PyTorch из колбы.Я не уверен, есть ли учебник по этому вопросу (пока не могу найти).