Install Tensorflow Object Detection API for

I have trained a model using Tensorflow 2 Object Detector API on a remote server. The server has the following setup:

  • Tensorflow 2.3.1
  • CUDA 10.1
  • cuDNN 7.6
  • Python 3.6.8
  • Ubuntu 16.04
  • Docker 18.09.2

The model I used for my project is the (EfficientDet D4 1024x1024). The trained model is working well, so then I exported the model using the exporter_main_v2.py from Tensorflow.

Now I would like to use the exported model into my Jetson TX2 for inference. For this I have pulled the docker image with the following setup:

  • Tensorflow 2.3.1+nv20.11
  • CUDA 10.2
  • cuDNN NA
  • Python 3.6.9
  • Ubuntu 16.04 LTS
  • Docker 18.09.2

For the inference on the Jetson TX2, I used this guide Tensorflow 2 Object Detector API. In the aforemetioned guide, I realized that I needed to install the Tensorflow 2 Object Detector API to perform inference on the Jetson TX2. The commands I executed in the docker container to install the Tensorflow 2 Object Detector API were almost the same as the remote server (Except from the protoc):

curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protoc-3.17.3-linux-aarch_64.zip
unzip protoc-3.17.3-linux-aarch_64.zip -d /usr/local bin/protoc)
unzip protoc-3.17.3-linux-aarch_64.zip -d /usr/local include/*
rm -f protoc-3.17.3-linux-aarch_64.zip
git clone https://github.com/tensorflow/models.git)
cd models/research
protoc object_detection/protos/*.proto --python_out=.
cp object_detection/packages/tf2/setup.py .
python3 -m pip install --use-feature=2020-resolver .

However, when I executed the last command python3 -m pip install --use-feature=2020-resolver .. It gives me the following error:

ERROR: Could not find a version that satisfies the requirement tensorflow>=2.5.0 (from tf-models-official) (from versions: none)
ERROR: No matching distribution found for tensorflow>=2.5.0

According to the pip Tensorflow-addons. There is no support for the hardware architecture of the JetsonTX2 (aarch64) on linux, and that might be causing the error.

My Questions are:

  • Is there a way get rid off the above error?
  • Is there any guide on how to install Tensorflow 2 Object Detector API on the Jetson TX2?
  • Is it necessary to install Tensorflow 2 Object Detector API on the Jetson TX2 to perform inference?

Hi,

The error requires a newer TensorFlow version.

ERROR: Could not find a version that satisfies the requirement tensorflow>=2.5.0

Which JetPack do you use?
For JetPack 4.6, you can find a TensorFlow 2.5.0 docker below:

For the JetPack 4.5.x environment, you can manually install it from the below document (outside of the docker):

$ sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v45 tensorflow

Thanks.

I just checked the JetPack Version and it is the Jetpack 3.3, and the docker container I was using for the project is JetPack 4.5. I asume that I will need to reinstall the JetPack to a newer version to succesfully execute my code on the JetsonTX2.

My Questions are:

  • Is there any way to have two Jetpack version in the JetsonTX2?
  • Is there any guide on how to install Jetpack?

Hello, I just flashed my Jetson TX2 with Jetpack 4.5.0. Then pulled a docker image for nvidia-l4t-tensorflow Jetpack 4.5.0, and I executed the same commands as above:

curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protoc-3.17.3-linux-aarch_64.zip
unzip protoc-3.17.3-linux-aarch_64.zip -d /usr/local bin/protoc)
unzip protoc-3.17.3-linux-aarch_64.zip -d /usr/local include/*
rm -f protoc-3.17.3-linux-aarch_64.zip
git clone https://github.com/tensorflow/models.git)
cd models/research
protoc object_detection/protos/*.proto --python_out=.
cp object_detection/packages/tf2/setup.py .
python3 -m pip install --use-feature=2020-resolver .

However, I get the following error in the last command:

INFO: pip is looking at multiple versions of <Python from Requires-Python> to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of object-detection to determine which version is compatible with other requirements. This could take a while.
ERROR: Cannot install object-detection because these package versions have conflicting dependencies.

The conflict is caused by:
    tf-models-official 2.6.0 depends on tensorflow-addons
    tf-models-official 2.5.1 depends on tensorflow-addons

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

I tried to install tensorflow-addons, but I get the same error as in the previous jetpack 3.3:

ERROR: Could not find a version that satisfies the requirement tensorflow-addons (from versions: none)
ERROR: No matching distribution found for tensorflow-addons

I run out of ideas, have someone installed Tensorflow Object Detection API on a Jetson TX2 with tensorflow 2.X.X?

Thanks for the help.

Hi,

The error indicates that a missing library called tensorflow-addon.
(tensorflow-addon is different from tensorflow)

To install it, please find some information in the below comment:

Thanks.

Thank you I was able to solve the previous problem by changing the docker image to JetPack 4.6 L4T R32.6.1 with Tensorflow 2.5.0 and manually installing tensorflow-addons on the Jetson TX2 from Tensorflow-Addons 0.14.0.

However, when executing the command python3 -m pip install --use-feature=2020-resolver . inside the models/reseach I get the following error:

Building wheels for collected packages: object-detection, kaggle, psutil, py-cpuinfo, dm-tree, avro-python3, crcmod, dill, docopt, matplotlib, pycocotools, seqeval, promise
  Building wheel for object-detection (setup.py) ... done
  Created wheel for object-detection: filename=object_detection-0.1-py3-none-any.whl size=1661340 sha256=c8706e900fcd8898065b359762c9e28384eb8656889bffe5109bbcf44fb0d314
  Stored in directory: /tmp/pip-ephem-wheel-cache-ie4l9720/wheels/df/9f/9f/86c64449ee4e9da1adc2b5e31fa4410663032c15db1b451435
  Building wheel for kaggle (setup.py) ... done
  Created wheel for kaggle: filename=kaggle-1.5.12-py3-none-any.whl size=73052 sha256=a45d4df260f23a0ce0d204c1ea1bdc15dfe695242b5a5e0f2dc93eea50e9138a
  Stored in directory: /root/.cache/pip/wheels/77/47/e4/44a4ba1b7dfd53faaa35f59f1175e123b213ff401a8a56876b
  Building wheel for psutil (setup.py) ... done
  Created wheel for psutil: filename=psutil-5.8.0-cp36-cp36m-linux_aarch64.whl size=290397 sha256=4a210b5949b39e145955f683511789bd639eb436e0dc4db4260e015fecaba5ee
  Stored in directory: /root/.cache/pip/wheels/6d/de/48/9e3627ec70b2df62377606d4fbe106025e60da976b8c7adabc
  Building wheel for py-cpuinfo (setup.py) ... done
  Created wheel for py-cpuinfo: filename=py_cpuinfo-8.0.0-py3-none-any.whl size=22257 sha256=dcad787da5e0e106b632244ab457df3e7caaf12773a672aa5e04f7722103207a
  Stored in directory: /root/.cache/pip/wheels/3e/e1/d9/9b782b170e5272d6500cee4d29dd6c724598b22dc399d81d01
  Building wheel for dm-tree (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-4z41p2w2/dm-tree_cfeea42554c546a0809aaf667f44bc2c/setup.py'"'"'; __file__='"'"'/tmp/pip-install-4z41p2w2/dm-tree_cfeea42554c546a0809aaf667f44bc2c/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-vsmc5nbh
       cwd: /tmp/pip-install-4z41p2w2/dm-tree_cfeea42554c546a0809aaf667f44bc2c/
  Complete output (13 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-aarch64-3.6
  creating build/lib.linux-aarch64-3.6/tree
  copying tree/tree_benchmark.py -> build/lib.linux-aarch64-3.6/tree
  copying tree/tree_test.py -> build/lib.linux-aarch64-3.6/tree
  copying tree/__init__.py -> build/lib.linux-aarch64-3.6/tree
  running build_ext
  bazel build //tree:_tree --symlink_prefix=build/temp.linux-aarch64-3.6/bazel- --compilation_mode=opt
  unable to execute 'bazel': No such file or directory
  error: command 'bazel' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for dm-tree

Is there a way to solve this? Thanks for all the support.

Hi,

The error complains about a missing binary called bazel.
You can install it via building from the source.

Below is a script from our user for your reference.
You may need to upgrade to version 3.7.2 for the latest TensorFlow release.

Thanks.