Install Tensorflow Object Detection API without replacing existing Tensorflow package

Viewed 476

I'm trying to build a custom container image based on AWS SageMaker 763104351884.dkr.ecr.us-east-1.amazonaws.com/tensorflow-training:2.3.0-gpu-py37-cu102-ubuntu18.04 image and following the instructions in https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#tensorflow-object-detection-api-installation

However, it seems that when I run the following commands, pip install replaces the already existing TensorFlow package with tensorflow-2.3.0-cp37-cp37m-manylinux2010_x86_64.whl which doesn't support AWS's CPU instructions and GPU devices.

# From within TensorFlow/models/research/
cp object_detection/packages/tf2/setup.py .
python -m pip install .

How can I install the Object Detection API without replacing existing TensorFlow? I tried python -m pip install --ignore-installed . but it doesn't seem to have any effect.

Update 1:

It seems that the already installed tensorflow for that AWS docker image isn't detected by pip even though it's available in /usr/local/lib/python3.7/site-packages/tensorflow. This is why pip still attempts to install it even with --ignore-installed.

As a workaround, I make a copy of the directory and then replace the newly installed one with it.

mv /usr/local/lib/python3.7/site-packages/tensorflow/ /usr/local/lib/python3.7/site-packages/tensorflow.cpy/
# From within TensorFlow/models/research/
cp object_detection/packages/tf2/setup.py .
python -m pip install .
rm -r /usr/local/lib/python3.7/site-packages/tensorflow/
mv /usr/local/lib/python3.7/site-packages/tensorflow.cpy/ /usr/local/lib/python3.7/site-packages/tensorflow/
0 Answers
Related