Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP-DL tutorial/tvm_example No module named 'tvm.relay.op.contrib.esp' (IDFGH-12113) (AIV-678) #154

Open
3 tasks done
MarkMendelsohn opened this issue Feb 12, 2024 · 4 comments

Comments

@MarkMendelsohn
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

5.0

Operating System used.

Linux

How did you build your project?

Command line with Make

If you are using Windows, please specify command line type.

None

What is the expected behavior?

successful build

What is the actual behavior?

esp-dl/tutorial/tvm_example$ . ./script.sh
Collecting tensor data and making histogram ...
Finding optimal threshold for each tensor using entropy algorithm ...
Number of tensors : 25
Number of histogram bins : 128 (The number may increase depends on the data it collects)
Number of quantized bins : 128
WARNING:root:Please use QuantFormat.QDQ for activation type QInt8 and weight type QInt8. Or it will lead to bad performance on x64.
Traceback (most recent call last):
File "../../tools/tvm/export_onnx_model.py", line 11, in
from tvm.relay.op.contrib.esp import preprocess_onnx_for_esp, evaluate_onnx_for_esp
ModuleNotFoundError: No module named 'tvm.relay.op.contrib.esp'

Steps to reproduce.

cd esp-dl/tutorial/tvm_example

. ./script.sh

Build or installation Logs.

esp-dl/tutorial/tvm_example$ . ./script.sh 
Collecting tensor data and making histogram ...
Finding optimal threshold for each tensor using entropy algorithm ...
Number of tensors : 25
Number of histogram bins : 128 (The number may increase depends on the data it collects)
Number of quantized bins : 128
WARNING:root:Please use QuantFormat.QDQ for activation type QInt8 and weight type QInt8. Or it will lead to bad performance on x64.
Traceback (most recent call last):
  File "../../tools/tvm/export_onnx_model.py", line 11, in <module>
    from tvm.relay.op.contrib.esp import preprocess_onnx_for_esp, evaluate_onnx_for_esp
ModuleNotFoundError: No module named 'tvm.relay.op.contrib.esp'

More Information.

Also tried on Mac Intel, M1 and M2 and Windows 11

@github-actions github-actions bot changed the title ESP-DL tutorial/tvm_example No module named 'tvm.relay.op.contrib.esp' ESP-DL tutorial/tvm_example No module named 'tvm.relay.op.contrib.esp' (IDFGH-12113) Feb 12, 2024
@MarkMendelsohn
Copy link
Author

Working on Linux now, but not the other platforms.

the downloads.sh only seems to get libtvm*.so files for Linux but not libtvm*.dylib files for the Mac

@igrr igrr transferred this issue from espressif/esp-idf Feb 13, 2024
@github-actions github-actions bot changed the title ESP-DL tutorial/tvm_example No module named 'tvm.relay.op.contrib.esp' (IDFGH-12113) ESP-DL tutorial/tvm_example No module named 'tvm.relay.op.contrib.esp' (IDFGH-12113) (AIV-678) Feb 13, 2024
@BlueSkyB
Copy link
Collaborator

You can refer to the following link for details: https://docs.espressif.com/projects/esp-dl/en/latest/esp32s3/tutorials/deploying-models-through-tvm.html#set-tvm-package-path

Check if the PYTHONPATH environment variable is set to the correct value, ensuring that the path matches the local tvm/python folder path (export PYTHONPATH=$PYTHONPATH:/path-to-esp-dl/esp-dl/tools/tvm/python).

@MarkMendelsohn
Copy link
Author

MarkMendelsohn commented Feb 19, 2024

On Ubuntu, the following output is produced:

esp-dl/tutorial/tvm_example$ . ./script.sh
Collecting tensor data and making histogram ...
Finding optimal threshold for each tensor using entropy algorithm ...
Number of tensors : 25
Number of histogram bins : 128 (The number may increase depends on the data it collects)
Number of quantized bins : 128
WARNING:root:Please use QuantFormat.QDQ for activation type QInt8 and weight type QInt8. Or it will lead to bad performance on x64.
Model Information:

Input Name: input_1
Input Shape: (1, 32, 32, 3)
Input DType: float
Output Name: Identity
Output Shape: (1, 10)
Output DType: float
One or more operators have not been tuned. Please tune your model for better performance. Use DEBUG logging level to see more details.
esp_dl_library_path: /media/mpm/FiveTDrive/esp-dl
generated project in: ./new_project

The environment variable is set:
$ env | grep PY
PYTHONPATH=/media/mpm/FiveTDrive/esp-dl/tools/tvm/python

Also:

esp-dl/tools/tvm/python/tvm$ file *.so
libtvm_runtime.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=b282dcf2103ca41ed42da59b5cab959277d8cac6, with debug_info, not stripped
libtvm.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=c635d10c85e10f342ea6b2d48de8b8056125536b, with debug_info, not stripped

On the MAC:

RuntimeError: Cannot find libraries: ['libtvm.dylib', 'libtvm_runtime.dylib'

There or no libraries by this name on the MAC and the .so libraries are not compatible with this platform

@BlueSkyB
Copy link
Collaborator

Your previous error was: “ModuleNotFoundError: No module named 'tvm.relay.op.contrib.esp'.”
So, has your problem been resolved on the Ubuntu platform? Currently, it is not supported on macOS platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants