aws-samples / amazon-sagemaker-tensorflow-object-detection-api

Train and deploy models using TensorFlow 2 with the Object Detection API on Amazon SageMaker
MIT No Attribution
42 stars 34 forks source link

Error in pip's dependency #11

Closed nfbalbontin closed 3 years ago

nfbalbontin commented 3 years ago

Hi! I'm having some problems with pip dependencies when running

!sh ./docker/build_and_push.sh $image_uri

inside /amazon-sagemaker-tensorflow-object-detection-api/2_train_model/train_model.ipynb. It throws the following error:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tf-nightly 2.5.0.dev20210308 requires gast==0.4.0, but you have gast 0.3.3 which is incompatible.
tf-nightly 2.5.0.dev20210308 requires grpcio~=1.34.0, but you have grpcio 1.32.0 which is incompatible.
tf-nightly 2.5.0.dev20210308 requires h5py~=3.1.0, but you have h5py 2.10.0 which is incompatible.

I try fixing it by adding the following lines to the Dockerfile:

FROM tensorflow/tensorflow:nightly-gpu

ARG DEBIAN_FRONTEND=noninteractive

# Install apt dependencies

####NEW SEGMENT######## 
RUN pip install --upgrade pip
########################
RUN apt-get update && apt-get install -y \
    apt-utils \
    git \
    gpg-agent \
    python3-cairocffi \
    protobuf-compiler \
    python3-pil \
    python3-lxml \
    python3-tk \
    libgl1-mesa-dev \
    wget

####NEW SEGMENT######## 
RUN python3 -m pip install \
    gast==0.4.0 \
    grpcio==1.34.0 \
    h5py==3.1.0 
########################

# Copy this version of of the model garden into the image
COPY models/research/object_detection /home/tensorflow/models/research/object_detection 

# Compile protobuf configs
RUN (cd /home/tensorflow/models/research/ && protoc object_detection/protos/*.proto --python_out=.)
WORKDIR /home/tensorflow/models/research/

RUN cp object_detection/packages/tf2/setup.py ./
ENV PATH="/home/tensorflow/.local/bin:${PATH}"
RUN python -m pip install -U pip
RUN python -m pip install .

ENV TF_CPP_MIN_LOG_LEVEL 3

# Install SageMaker training-toolkit
RUN pip3 install sagemaker-training

But I get the same error :(.

sofianhamiti commented 3 years ago

Yes that happens with the nightly-gpu version. However I have temporary put this one as it can use the GPU when training, as compared to 2.4.1. Waiting for the TF team to update repo so we can reflect here too. The error didn't see to impact the training though. You may check further on the main TF Object Detection API repo.