SMARC iMX95 - NPU Tensor Flowlite Model

Hi,

I ran the eIQ TensorFlow Lite example models on the NPU, but they fail with the following errors:
INFO: Loaded model mobilenet_v1_1.0_224_quant.tflite
INFO: resolved reporter
INFO: EXTERNAL delegate created.
remoteproc remoteproc0: Booting fw image NeutronFirmware.elf
remoteproc remoteproc0: remote processor neutron-rproc is now up
INFO: NeutronDelegate delegate: 29 nodes delegated out of 31 nodes with 1 partition.
INFO: Applied EXTERNAL delegate.
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
neutron 4ab00004.imx95-neutron: Invalid ioctl. cmd=1075577096, arg=549719032088
fail to create neutron inference job
Error: component='Neutron Driver', category='internal fault', code=442
ERROR: Node number 31 (NeutronDelegate) failed to invoke.
ERROR: Failed to invoke tflite!

The examples were built using the following package:

# AI/ML
IMAGE_INSTALL:append = " tensorflow-lite-neutron-delegate"

Currently, the remote processor shows as offline:

root@toradex-smarc-imx95-12593622:/sys/class/remoteproc/remoteproc0# cat state
offline

When attempting to start the remote processor manually, I encounter permission errors:

root@toradex-smarc-imx95-12593622:~# echo rproc-neutron-rproc-fw > /sys/class/remoteproc/remoteproc0/firmware
-sh: /sys/class/remoteproc/remoteproc0/firmware: Permission denied

root@toradex-smarc-imx95-12593622:~# echo start > /sys/class/remoteproc/remoteproc0/state
-sh: /sys/class/remoteproc/remoteproc0/state: Permission denied

Hi, I’m the Toradex AI Assistant.

I might make mistakes or occasionally get you wrong. Our support team will step in if needed.


TensorFlow Lite NPU Issues with Permission Errors

Based on your error messages, you’re encountering both RemoteProc permission issues and NPU delegate failures. Let me help you resolve these step by step.

1. RemoteProc Permission Issues

The permission errors you’re seeing when trying to manually control the remote processor are common. According to the RemoteProc documentation (1), you need to ensure the remote processor is in the correct state before making changes.

First, check if the remote processor state is properly accessible (1):

# cat /sys/class/remoteproc/remoteproc0/state

(1)

If you’re getting permission denied errors, try stopping the remote processor first (1):

# echo stop > /sys/class/remoteproc/remoteproc0/state

(1)

Then verify it’s offline (1):

# cat /sys/class/remoteproc/remoteproc0/state
offline

(1)

2. Firmware Loading Process

For loading firmware, the RemoteProc framework looks for *.elf firmware stored inside /lib/firmware by default (1). You can copy your firmware to this location (1):

$ scp hello_world.elf root@<board-ip>:/lib/firmware

(1)

If your firmware is stored elsewhere, you can update the firmware path (1):

# echo -n new_path > /sys/module/firmware_class/parameters/path

(1)

Since Torizon OS has a Read Only filesystem, copy the firmware to another location like /tmp/ and update the path accordingly (1).

3. Loading and Starting the Remote Processor

To load your firmware, write its name to the firmware file (1):

# echo <firmware>.elf > /sys/class/remoteproc/remoteproc0/firmware

(1)

Important: Make sure to run a *.elf firmware, otherwise it will not work (1).

To start the remote processor with the new firmware (1):

# echo start > /sys/class/remoteproc/remoteproc0/state

(1)

You should see output similar to (1):

[12594.692880] remoteproc remoteproc0: powering up imx-rproc
[12594.698629] remoteproc remoteproc0: Booting fw image hello_world.elf, size 240736
[12594.706192] remoteproc remoteproc0: no dtb rsrc-table
[12594.761474] remoteproc remoteproc0: remote processor imx-rproc is now up

(1)

4. NPU Configuration Requirements

Based on the community discussions, there are several important considerations for NPU setup (2):

  1. Verify NPU Support: Ensure that your hardware supports NPU execution and that the TensorFlow Lite version you are using is compatible with NPU acceleration (2)

  2. Install NPU Drivers: Make sure NPU drivers are properly installed and configured (2)

  3. Use the Correct TensorFlow Lite Delegate: Ensure you are using the appropriate delegate for NPU execution (2)

5. Troubleshooting Steps

  1. Check Hardware Support: Verify your hardware configuration supports the NPU delegate
  2. Firmware Verification: Ensure the correct NPU firmware is loaded
  3. Driver Status: Check if the neutron driver is properly loaded and accessible
  4. Delegate Configuration: Verify the TensorFlow Lite delegate is correctly configured for your specific hardware

The error message Invalid ioctl. cmd=1075577096 suggests there may be a mismatch between the driver and the delegate or firmware versions.

6. Alternative Approach

If you continue experiencing issues, consider testing with CPU-only inference first to isolate whether the problem is specifically with NPU acceleration (3). You can disable hardware acceleration temporarily with USE_HW_ACCELERATED_INFERENCE=0 (3).


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Hi, just following up to check if anyone has insights on this issue. Thanks in advance