【发布时间】:2021-03-13 20:33:55
【问题描述】:
由于 tensorflow-nightly 的 GPU 支持是 currently broken on Google Colab,我正在尝试构建自己的 docker 映像以进行开发。但是,当我从 tensorflow/models 安装 object_detection 包时,我的夜间 tensorflow 包被作为依赖项从 object_detection setup.py 拉入的版本覆盖。
我在 Google Colab 中遵循基本相同的步骤,但我的 tensorflow nightly 没有在那里被覆盖,所以我不确定我错过了什么......
这是我的Dockerfile:
FROM tensorflow/tensorflow:nightly-gpu-jupyter
RUN python -c "import tensorflow as tf; print(f'Tensorflow version: {tf.__version__}')"
RUN apt-get install -y \
curl \
git \
less \
zip
RUN curl -L -O https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/protoc-3.11.4-linux-x86_64.zip && unzip protoc-3.11.4-linux-x86_64.zip
RUN cp bin/protoc /usr/local/bin
RUN git clone --depth 1 https://github.com/tensorflow/models
RUN cd models/research && \
protoc object_detection/protos/*.proto --python_out=. && \
cp object_detection/packages/tf2/setup.py . && \
python -m pip install .
RUN python -c "import tensorflow as tf; print(f'Tensorflow version: {tf.__version__}')"
我正在构建的:
docker pull tensorflow/tensorflow:nightly-gpu-jupyter
docker build --no-cache . -f models-tf-nightly.Dockerfile -t tf-nightly-models
第一个print()显示:
Tensorflow version: 2.5.0-dev20201129
但第二个显示:
Tensorflow version: 2.3.1
在 Google Colab 中,我执行的步骤基本相同:
# Install the Object Detection API
%%bash
pip install tf-nightly-gpu
[[ -d models ]] || git clone --depth 1 https://github.com/tensorflow/models
cd models/research/
protoc object_detection/protos/*.proto --python_out=.
cp object_detection/packages/tf2/setup.py .
python -m pip install .
之后
import tensorflow as tf
print(tf.__version__)
打印2.5.0-dev20201201
所以不知何故,我的 Google Colab 步骤保留了我的夜间 Tensorflow 安装,而在 Docker 上它被 2.3.0 覆盖。
【问题讨论】:
标签: python docker tensorflow pip tensorflow-model-garden