installing of retina-net-examples on Jetson Xavier


I am trying to install retina-net-examples from github on my Jetson Xavier
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/”, 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/”, line 2852, in load_entry_point
return ep.load()
File “/home/foresight/.local/lib/python3.6/site-packages/pkg_resources/”, line 2443, in load
return self.resolve()
File “/home/foresight/.local/lib/python3.6/site-packages/pkg_resources/”, 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/”, 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/”, 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/”, 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/”, line 10, in
File “/usr/local/lib/python3.6/dist-packages/apex-0.9.10.dev0-py3.6.egg/apex/”, line 14, in ApexImplementation
File “/home/foresight/.local/lib/python3.6/site-packages/zope/interface/”, 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?


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

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:

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:

  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
pip install --no-cache-dir git+

  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?


Also found this link:

Still no success.


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__
>>> import torchvision
>>> torchvision.__version__

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
Collecting torchvision (from odtk==0.2.0)
  Using cached
Collecting pillow (from odtk==0.2.0)
  Using cached
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 install for pbkdf2 ... done
  Running install for cryptacular ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-d4x4exp0/cryptacular/';f=getattr(tokenize, 'open', open)(__file__);'\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/';f=getattr(tokenize, 'open', open)(__file__);'\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 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?