Python - Невозможно обучить контейнер модели Tensorflow в Sagemaker - PullRequest
0 голосов
/ 16 марта 2020

Я довольно новичок в Sagemaker и Docker. Я пытаюсь обучить свой собственный алгоритм обнаружения объектов в Sagemaker, используя контейнер ECS. Я использую файлы этого репо:

https://github.com/svpino/tensorflow-object-detection-sagemaker

Я точно следовал инструкциям и могу отлично запустить изображение в контейнере нормально на моей локальной машине. Но когда я помещаю sh образ в ECS для запуска в Sagemaker, я получаю следующее сообщение в Cloudwatch: I get the following error message in Cloudwatch:

Я понимаю, что по какой-то причине при развертывании в ECS вдруг изображение не может найти python. В верхней части моего учебного скрипта находится текст #! / Usr / bin / env python. Я попытался запустить команду * which python * и изменил текст так, чтобы он указывал на #! / Usr / local / bin python, но я просто получаю дополнительные ошибки. Я не понимаю, почему этот образ будет работать на моем локальном компьютере (протестировано с docker на windows и docker CE для WSL). Вот фрагмент файла docker:

ARG ARCHITECTURE=1.15.0-gpu
FROM tensorflow/tensorflow:${ARCHITECTURE}-py3

RUN apt-get update && apt-get install -y --no-install-recommends \
        wget zip unzip git ca-certificates curl nginx python

# We need to install Protocol Buffers (Protobuf). Protobuf is Google's language and platform-neutral,  
# extensible mechanism for serializing structured data. To make sure you are using the most updated code,
# replace the linked release below with the latest version available on the Git repository.
RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.10.1/protoc-3.10.1-linux-x86_64.zip
RUN unzip protoc-3.10.1-linux-x86_64.zip -d protoc3
RUN mv protoc3/bin/* /usr/local/bin/
RUN mv protoc3/include/* /usr/local/include/

# Let's add the folder that we are going to be using to install all of our machine learning-related code
# to the PATH. This is the folder used by SageMaker to find and run our code.
ENV PATH="/opt/ml/code:${PATH}"
RUN mkdir -p /opt/ml/code
WORKDIR /opt/ml/code

RUN pip install --upgrade pip
RUN pip install cython
RUN pip install contextlib2
RUN pip install pillow
RUN pip install lxml
RUN pip install matplotlib
RUN pip install flask
RUN pip install gevent
RUN pip install gunicorn
RUN pip install pycocotools

# Let's now download Tensorflow from the official Git repository and install Tensorflow Slim from
# its folder.
RUN git clone https://github.com/tensorflow/models/ tensorflow-models
RUN pip install -e tensorflow-models/research/slim

# We can now install the Object Detection API, also part of the Tensorflow repository. We are going to change
# the working directory for a minute so we can do this easily.
WORKDIR /opt/ml/code/tensorflow-models/research
RUN protoc object_detection/protos/*.proto --python_out=.
RUN python setup.py build
RUN python setup.py install

# If you are interested in using COCO evaluation metrics, you can tun the following commands to add the
# necessary resources to your Tensorflow installation.
RUN git clone https://github.com/cocodataset/cocoapi.git
WORKDIR /opt/ml/code/tensorflow-models/research/cocoapi/PythonAPI
RUN make 
RUN cp -r pycocotools /opt/ml/code/tensorflow-models/research/

# Let's put the working directory back to where it needs to be, copy all of our code, and update the PYTHONPATH
# to include the newly installed Tensorflow libraries.
WORKDIR /opt/ml/code
COPY /code /opt/ml/code

ENV PYTHONPATH=${PYTHONPATH}:tensorflow-models/research:tensorflow-models/research/slim:tensorflow-models/research/object_detection

RUN chmod +x /opt/ml/code/train
CMD ["/bin/bash","-c","chmod +x /opt/ml/code/train && /opt/ml/code/train"]
...