installing of retina-net-examples on Jetson Xavier

Hi,

I am trying to install retina-net-examples from github on my Jetson Xavier
https://github.com/NVIDIA/retinanet-examples.
Installation seems to pass correct but when trying to convert from pth to onnx by running the following command:
retinanet export retinanet_rn50fpn.pth retinanet_rn50fpn.plan --batch 1 --size 1280

i get the following errors:

Traceback (most recent call last):
File “/usr/local/bin/retinanet”, line 11, in
load_entry_point(‘retinanet==0.1’, ‘console_scripts’, ‘retinanet’)()
File “/home/foresight/.local/lib/python3.6/site-packages/pkg_resources/init.py”, line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/home/foresight/.local/lib/python3.6/site-packages/pkg_resources/init.py”, line 2852, in load_entry_point
return ep.load()
File “/home/foresight/.local/lib/python3.6/site-packages/pkg_resources/init.py”, line 2443, in load
return self.resolve()
File “/home/foresight/.local/lib/python3.6/site-packages/pkg_resources/init.py”, line 2449, in resolve
module = import(self.module_name, fromlist=[‘name’], level=0)
File “/usr/local/lib/python3.6/dist-packages/retinanet-0.1-py3.6-linux-aarch64.egg/retinanet/main.py”, line 10, in
from retinanet import infer, train, utils
File “/usr/local/lib/python3.6/dist-packages/retinanet-0.1-py3.6-linux-aarch64.egg/retinanet/infer.py”, line 6, in
from apex import amp
File “”, line 971, in _find_and_load
File “”, line 955, in _find_and_load_unlocked
File “”, line 656, in _load_unlocked
File “”, line 626, in _load_backward_compatible
File “/usr/local/lib/python3.6/dist-packages/apex-0.9.10.dev0-py3.6.egg/apex/init.py”, line 18, in
File “”, line 971, in _find_and_load
File “”, line 955, in _find_and_load_unlocked
File “”, line 656, in _load_unlocked
File “”, line 626, in _load_backward_compatible
File “/usr/local/lib/python3.6/dist-packages/apex-0.9.10.dev0-py3.6.egg/apex/interfaces.py”, line 10, in
File “/usr/local/lib/python3.6/dist-packages/apex-0.9.10.dev0-py3.6.egg/apex/interfaces.py”, line 14, in ApexImplementation
File “/home/foresight/.local/lib/python3.6/site-packages/zope/interface/declarations.py”, line 483, in implements
raise TypeError(_ADVICE_ERROR % ‘implementer’)
TypeError: Class advice impossible in Python3. Use the @implementer class decorator instead.

Can anyone please advise?

Thanks,
Gabi

Hi Gabi, see these GitHub comments regarding the apex package issue:

https://github.com/NVIDIA/apex/issues/116#issuecomment-451828768

https://github.com/facebookresearch/maskrcnn-benchmark/issues/722#issuecomment-500817608

And if you search Google for “Class advice impossible in Python3”, you can find other similar workarounds. I’m not personally familiar with retinanet, but I did find these instructions for Xavier here:

https://github.com/NVIDIA/retinanet-examples/blob/master/INFERENCE.md#deployment-with-tensorrt-on-nvidia-jetson-agx-xavier

They recommend that you export to ONNX from a host PC and copy that over to your Xavier. If you have further questions, I recommend you post an issue to the retinanet GitHub. Thanks.

I tried to do as you suggested:

https://github.com/NVIDIA/retinanet-examples

  1. On my local PC download last pytourch with TensorRT 6.0.1 and install retinanet-examples:

docker run --gpus all --rm --ipc=host -it nvcr.io/nvidia/pytorch:19.09-py3
pip install --no-cache-dir git+https://github.com/nvidia/retinanet-examples

  1. convert pth file to onnx in my local PC
    retinanet export file.pth file.onnx --size y x

  2. On Xavier with JetPack 4.3 (TensorRT 6.0.1) i compiled only the extras/cppapi and used the export to convert from onnx to plan as follows:

./export file.onnx file.plan

All the conversions endded successfully, however instead of one rectangle of bounding box on the target, i see 2 rectangles in the shape of a cross on the target.

Can anyone please advise?

Thanks,
Gabi

Also found this link:

https://github.com/NVIDIA/retinanet-examples/tree/master/extras/deepstream

Still no success.

Gabi

So, I am not able to install it either. I installed PyTorch and torchvision using the instructions here.

They are for sure installed:

>>> import torch
>>> torch.__version__
'1.4.0'
>>> import torchvision
>>> torchvision.__version__
'0.5.0a0+85b8fbf'

But installing retinanet-examples does not work. I built a wheel, but it won’t install.

 $ pip3 install odtk-0.2.0-cp36-cp36m-linux_aarch64.whl 
Processing ./odtk-0.2.0-cp36-cp36m-linux_aarch64.whl
Collecting requests (from odtk==0.2.0)
  Using cached https://files.pythonhosted.org/packages/1a/70/1935c770cb3be6e3a8b78ced23d7e0f3b187f5cbfab4749523ed65d7c9b1/requests-2.23.0-py2.py3-none-any.whl
Collecting torchvision (from odtk==0.2.0)
  Using cached https://files.pythonhosted.org/packages/fb/01/03fd7e503c16b3dc262483e5555ad40974ab5da8b9879e164b56c1f4ef6f/torchvision-0.2.2.post3-py2.py3-none-any.whl
Collecting pillow (from odtk==0.2.0)
  Using cached https://files.pythonhosted.org/packages/39/47/f28067b187dd664d205f75b07dcc6e0e95703e134008a14814827eebcaab/Pillow-7.0.0.tar.gz
Collecting torch>=1.0.0a0 (from odtk==0.2.0)
  Could not find a version that satisfies the requirement torch>=1.0.0a0 (from odtk==0.2.0) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
No matching distribution found for torch>=1.0.0a0 (from odtk==0.2.0)

If I try to install it globally, since torchvision won’t do a --user install on tegra, i get this:

  Running setup.py install for pbkdf2 ... done
  Running setup.py install for cryptacular ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-d4x4exp0/cryptacular/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-13l7af_m-record/install-record.txt --single-version-externally-managed --compile:
    scons: Reading SConscript files ...
    scons: done reading SConscript files.
    scons: Building targets ...
    scons: *** Do not know how to make File target `install' (/tmp/pip-build-d4x4exp0/cryptacular/install).  Stop.
    scons: building terminated because of errors.
    
    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-d4x4exp0/cryptacular/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-13l7af_m-record/install-record.txt --single-version-externally-managed --compile" failed with error code 2 in /tmp/pip-build-d4x4exp0/cryptacular/

and if i install using sudo python3 setup.py install i get:

Successfully installed attrs-19.3.0 enscons-0.23.0 pytoml-0.1.21 scons-3.1.2 setuptools-46.0.0 wheel-0.34.2
scons: Reading SConscript files ...
SandboxViolation: SandboxViolation: mkdir('/tmp/enscons', 511) {}

The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been aborted.

This package cannot be safely installed by EasyInstall, and may not
support alternate installation locations even if you run its setup
script by hand.  Please inform the package's author and the EasyInstall
maintainers to find out if a fix or workaround is available.

Nvidia documentation seems to state that int8 calibration should be performed on the same device that the network is run on but in the case of Xavier I am not able to get it working and unfortunately I have no card for x86 that supports fast int8 (edit: apparently I do. supported by 1080). Apart from some example code that does similar things, I can find no int8 calibration tool.

My understanding is I need to do two things:

  • convert my .pth to an onnx
  • make a calibrated .plan with the supplied dataset

Unfortunately I am stuck, however, without a .pth to .onnx conversion. If it’s not possible to install retinanet-examples on xavier, is there an alternative conversion utility lying around in a repo somewhere?