在 Azure ML 上使用 Docker 时如何更改对象检测 API 使用的 tensorflow 版本

问题描述

我正在尝试使用 EfficientDet en Context R-CNN 算法进行某些对象检测。为此,我使用了 tensorflow 对象检测 API。我想在具有 Cuda 10.1、CDNN 7.0 和 Ubuntu 18 的 GPU NVIDIA Tesla K80 (STANDARD_NC6) 上使用 Azure ML 环境运行它。

为了安装依赖项,我按照检测 API 的说明向 Azure ML 计算调用添加一个 docker:

FROM mcr.microsoft.com/azureml/openmpi3.1.2-cuda10.1-cudnn7-ubuntu18.04

RUN pip install --ignore-installed --upgrade tensorflow==2.2.0

RUN mkdir /install
RUN mkdir /install/TensorFlow

workdir /install/TensorFlow

RUN wget https://github.com/tensorflow/models/archive/master.zip

RUN unzip master.zip
RUN mv models-master/ models/

RUN mkdir /install/proto
workdir /install/proto
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protoc-3.13.0-linux-x86_64.zip
RUN unzip protoc-3.13.0-linux-x86_64.zip
ENV PATH="${PATH}:/install/proto/bin"

workdir /install/TensorFlow/models/research
RUN /install/proto/bin/protoc object_detection/protos/*.proto --python_out=.

RUN cp object_detection/packages/tf2/setup.py .
RUN python -m pip install .

RUN python object_detection/builders/model_builder_tf2_test.py

workdir /
RUN echo "$PWD"

现在Azure 保存了Docker 镜像,所以之前使用这个镜像是没有问题的。我在使用内存时遇到了一些问题,所以我想重建它以添加一些检查,以便我可以解决这些问题。但似乎最新版本的 tensorflow (2.4) 已被纳入需求。这也意味着最新版本需要 CUDA 11.0 和 CDNN 8.0,而这些 GPU 尚不可用。

对象检测 API 文档在这里似乎已被弃用。因为我找不到定义我想要使用哪个版本的 Tensorflow 的方法。由于“object_detection/packages/tf2/setup.py”中的要求,它需要 tf-models-official,因此它总是转到 tensorflow 2.4。如果我在文件末尾使用 tensorflow 2.2.0 强制 Docker 重建:

 RUN pip install --ignore-installed --upgrade tensorflow==2.2.0

我收到环境错误

ERROR: apache-beam 2.26.0 has requirement avro-python3!=1.9.2,<1.10.0,>=1.8.1,but you'll have avro-python3 1.10.1 which is incompatible.
ERROR: apache-beam 2.26.0 has requirement dill<0.3.2,>=0.3.1.1,but you'll have dill 0.3.3 which is incompatible.
ERROR: apache-beam 2.26.0 has requirement httplib2<0.18.0,>=0.8,but you'll have httplib2 0.18.1 which is incompatible.
ERROR: tensorflow-Metadata 0.26.0 has requirement absl-py<0.11,>=0.9,but you'll have absl-py 0.11.0 which is incompatible.

由于 AzureML 处理 Dockerfile 的方式,我似乎也无法添加本地新 setup.py 文件添加完全正确的环境。有谁知道此问题的解决方法,以便我可以将本地文件添加到 Azure ML 使用的 Dockerfile,或者获取以 tensorflow 2.2 为基础的旧版本的 tensorflow 对象检测 API?

干杯!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)