How to install Anomalib (require psutil which do not have aarch64 binary for NVIDIA Jetson Nano B01) on NVIDIA Jetson Nano B01?

My goal is to use Anomalib on NVIDIA Jetson Nano B01 to detect anomaly from a frame. The frame input is from ArduCAM IMX519. The problem is that I can’t install Anomalib on NVIDIA Jetson Nano B01.

What I’ve tried:

  1. Install from GitHub repository
// create virtualenv
$ python3.8 -m virtualenv GoDataID_anomalib
$ . GoDataID_anomalib/bin/activate

$ git clone --branch abi3-linux-aarch64 https://github.com/mayeut/psutil.git
$ cd psutil
$ python -m pip install -e .

However, it throws error

(GoDataID_anomalib) werate-01@werate-01:~/psutil$ python -m pip install -e .
Obtaining file:///home/werate-01/psutil
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: psutil
  Building editable for psutil (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building editable for psutil (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [74 lines of output]
      running editable_wheel
      creating /tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info
      writing /tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/PKG-INFO
      writing dependency_links to /tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/dependency_links.txt
      writing requirements to /tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/requires.txt
      writing top-level names to /tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/top_level.txt
      writing manifest file '/tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/SOURCES.txt'
      reading manifest file '/tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'LICENSE'
      writing manifest file '/tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/SOURCES.txt'
      creating '/tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil-5.9.5.dist-info'
      creating /tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil-5.9.5.dist-info/WHEEL
      running build_py
      running build_ext
      building 'psutil._psutil_linux' extension
      creating /tmp/tmpzf6gr400.build-temp/psutil
      aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=595 -DPy_LIMITED_API=0x03060000 -DPSUTIL_LINUX=1 -I/home/werate-01/GoDataID_anomalib/include -I/usr/include/python3.8 -c psutil/_psutil_common.c -o /tmp/tmpzf6gr400.build-temp/psutil/_psutil_common.o
      psutil/_psutil_common.c:9:10: fatal error: Python.h: No such file or directory
       #include <Python.h>
                ^~~~~~~~~~
      compilation terminated.
      Traceback (most recent call last):
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/unixccompiler.py", line 186, in _compile
          self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/ccompiler.py", line 1007, in spawn
          spawn(cmd, dry_run=self.dry_run, **kwargs)
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
          raise DistutilsExecError(
      distutils.errors.DistutilsExecError: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/command/editable_wheel.py", line 140, in run
          self._create_wheel_file(bdist_wheel)
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/command/editable_wheel.py", line 330, in _create_wheel_file
          files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/command/editable_wheel.py", line 261, in _run_build_commands
          self._run_build_subcommands()
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/command/editable_wheel.py", line 288, in _run_build_subcommands
          self.run_command(name)
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 1213, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 84, in run
          _build_ext.run(self)
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
          self.build_extensions()
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 468, in build_extensions
          self._build_extensions_serial()
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 494, in _build_extensions_serial
          self.build_extension(ext)
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 246, in build_extension
          _build_ext.build_extension(self, ext)
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 549, in build_extension
          objects = self.compiler.compile(
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/ccompiler.py", line 599, in compile
          self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
        File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/unixccompiler.py", line 188, in _compile
          raise CompileError(msg)
      distutils.errors.CompileError: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1
      error: Support for editable installs via PEP 660 was recently introduced
      in `setuptools`. If you are seeing this error, please report to:
      
      https://github.com/pypa/setuptools/issues
      
      Meanwhile you can try the legacy behavior by setting an
      environment variable and trying to install again:
      
      SETUPTOOLS_ENABLE_FEATURES="legacy-editable"
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building editable for psutil
Failed to build psutil
ERROR: Could not build wheels for psutil, which is required to install pyproject.toml-based projects

[notice] A new release of pip available: 22.3.1 -> 23.0
[notice] To update, run: pip install --upgrade pip

Solution:

note: I have not tested it to inference.

# Install Python3.8
$ sudo apt-get update
$ sudo apt-get install python3.8

# Install pip on Python3.8
$ wget https://bootstrap.pypa.io/get-pip.py
$ python3.8 get-pip.py

# Upgrade pip
$ python3.8 -m pip install --upgrade pip

# Install virtualenv
$ python3.8 -m pip install virtualenv

# Create GoDataID_anomalib environment
$ python3.8 -m virtualenv -p python3.8 GoDataID_anomalib

# activate GoDataID_anomalib environment
$ . ./GoDataID_anomalib/bin/activate

# install psutil
$ python -m pip install psutil --find-links=https://ddelange.github.io/psutil/

# install anomalib
$ cd anomalib
$ python -m pip install -e .

Hi,
We don’t have this experience about using the package. Would need other users to check and share experience.

For running deep learning inference on Jetson platforms, we have DeepSstream SDK. If you are interested, please take a look at the documents:
NVIDIA Metropolis Documentation

I’m not a “python guy”, so I can’t answer much in the way of Python questions, but there is a general concept which Linux uses in packages: The development header files are almost always a separate “-dev” package from the libraries or programs themselves. The fact that it cannot find Python.h has virtually no relation to the arm64 architecture. What it really means is that you probably just have to install the right -dev package.

As an example, looking at a TX2, I have both a Python 2 and Python 3 version of Python.h:

/usr/include/python2.7/Python.h
/usr/include/python3.6m/Python.h

The packages which provide those:
libpython2.7-dev:arm64: /usr/include/python2.7/Python.h
libpython3.6-dev:arm64: /usr/include/python3.6m/Python.h

Since your builds are nothing Python 3.8, I’d start by updating the system (this can cause problems in older releases, but tends to work right in the more current releases):

sudo apt update
sudo apt-get upgrade

(you might be able to skip that, but I wouldn’t advise it)

To find related packages:
apt search python3.8

If you already have 3.8, then no problem, but otherwise you probably want to then:
sudo apt-get install python3.8

Followed by:
sudo apt-get install python3.8-dev

Don’t forget to check disk space first.

Can confirm:

  1. Can install anomalib but can’t run anomalib.
apt-get update
apt-get install python3.8 python3.8-dev
wget https://bootstrap.pypa.io/get-pip.py
python3.8 get-pip.py
python3.8 -m pip install anomalib

I’m pretty useless with Python debugging, but if you get an error message upon running, then post that. Also, verify that the startup is using python3 and not python2 (which may be the default) if it is python3 software. For example, if a script starts it with “python ...something...”, then perhaps “python” is python2 and needs to be python3.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.