-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Improve tvmc error message from lazy-loading frontend imports #9074
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this change @ophirfrish, having met these errors many times it's great to get some guidance from tvmc
- I've just a few suggestions 😸
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM - a few improvements to be done in the tests.
@ophirfrish please address the comments and the ci failure (maybe just need to re-submit as CI was flaky the past week or two). |
I am still working on some of the comments I got. Will submit the updated code once all comments are resolved
From: Andrew Reusch ***@***.***>
Sent: Sunday, October 3, 2021 8:38 PM
To: apache/tvm ***@***.***>
Cc: Ophir Frish ***@***.***>; Mention ***@***.***>
Subject: Re: [apache/tvm] Improve tvmc error message from lazy-loading frontend imports (#9074)
@ophirfrish<https://github.com/ophirfrish> please address the comments and the ci failure (maybe just need to re-submit as CI was flaky the past week or two).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#9074 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AKEKISZ7NTGFVUK4PNVIS7DUFCIHPANCNFSM5EQ3FKZA>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ophirfrish thanks! i think @leandron is out for a bit, so i'm reviewing here. in general there are just a couple cleanups here and there, but also a suggestion if you're up for it.
3d5cac2
to
7a4e2bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ophirfrish, I checked this out locally and I don't think this is working as intended:
$ tvmc compile resnet18-f37072fd.pth --target=llvm
2021-11-24 12:24:39.653314: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2021-11-24 12:24:39.653347: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
[12:24:41] /workspaces/tvm-sandbox-micro/src/tvm/src/target/target_kind.cc:164: Warning: Unable to detect CUDA version, default to "-mcpu=sm_20" instead
[12:24:41] /workspaces/tvm-sandbox-micro/src/tvm/src/target/target_kind.cc:190: Warning: Unable to detect ROCm compute arch, default to "-mcpu=gfx900" instead
[12:24:41] /workspaces/tvm-sandbox-micro/src/tvm/src/target/target_kind.cc:204: Warning: Unable to detect ROCm version, assuming >= 3.5
[12:24:41] /workspaces/tvm-sandbox-micro/src/tvm/src/target/target_kind.cc:164: Warning: Unable to detect CUDA version, default to "-mcpu=sm_20" instead
[12:24:41] /workspaces/tvm-sandbox-micro/src/tvm/src/target/target_kind.cc:190: Warning: Unable to detect ROCm compute arch, default to "-mcpu=gfx900" instead
[12:24:41] /workspaces/tvm-sandbox-micro/src/tvm/src/target/target_kind.cc:204: Warning: Unable to detect ROCm version, assuming >= 3.5
Traceback (most recent call last):
File "/workspaces/tvm-sandbox-micro/src/tvm/python/tvm/driver/tvmc/frontends.py", line 88, in lazy_import
return importlib.import_module(pkg_name, package=from_pkg_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'torch'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/workspaces/tvm-sandbox-micro/src/tvm/python/tvm/driver/tvmc/main.py", line 94, in _main
return args.func(args)
File "/workspaces/tvm-sandbox-micro/src/tvm/python/tvm/driver/tvmc/compiler.py", line 143, in drive_compile
tvmc_model = frontends.load_model(args.FILE, args.model_format, args.input_shapes)
File "/workspaces/tvm-sandbox-micro/src/tvm/python/tvm/driver/tvmc/frontends.py", line 402, in load_model
mod, params = frontend.load(path, shape_dict, **kwargs)
File "/workspaces/tvm-sandbox-micro/src/tvm/python/tvm/driver/tvmc/frontends.py", line 251, in load
torch = lazy_import("torch", hide_stderr=True)
File "/workspaces/tvm-sandbox-micro/src/tvm/python/tvm/driver/tvmc/frontends.py", line 90, in lazy_import
raise TVMCImportError({pkg_name})
tvm.driver.tvmc.common.TVMCImportError: {'torch'}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/tvmc", line 33, in <module>
sys.exit(load_entry_point('tvm', 'console_scripts', 'tvmc')())
File "/workspaces/tvm-sandbox-micro/src/tvm/python/tvm/driver/tvmc/main.py", line 106, in main
sys.exit(_main(sys.argv[1:]))
File "/workspaces/tvm-sandbox-micro/src/tvm/python/tvm/driver/tvmc/main.py", line 97, in _main
f'Package "{err.message}" is not installed. ' f'Hint: "pip install tlcpack[tvmc]".'
AttributeError: 'TVMCImportError' object has no attribute 'message'
I've added suggestions to solve some of the above and simplify the PR but it'd be good to consider how we can automate the testing of this to avoid this kind of regression.
Otherwise, I think this is a great UX improvement, so ping me again when you've taken a look 😸
a397284
to
49ccc96
Compare
When installing TVM from the python package, the Frontend frameworks dependencies such as TensorFlow, PyTorch, ONNX, etc, are not installed by default. In case a user tries to run tvmc using a model whose framework was not installed, it will be presented with a very raw Python exception in the output. The aim of this commit is to implement a better error messages for errors related to lazy-loading frontend frameworks in tvmc. Change-Id: Ida52fac4116af392ee436390e14ea02c7090cef0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. We had a few comments from @Mousius, which seems fixed now, so let us merge this one and for any new suggestions, we can fix on follow-up PRs.
Thanks @ophirfrish @Mousius @areusch!
We'll fix any remaining issue in follow-up PRs.
…#9074) When installing TVM from the python package, the Frontend frameworks dependencies such as TensorFlow, PyTorch, ONNX, etc, are not installed by default. In case a user tries to run tvmc using a model whose framework was not installed, it will be presented with a very raw Python exception in the output. The aim of this commit is to implement a better error messages for errors related to lazy-loading frontend frameworks in tvmc. Change-Id: Ida52fac4116af392ee436390e14ea02c7090cef0
…#9074) When installing TVM from the python package, the Frontend frameworks dependencies such as TensorFlow, PyTorch, ONNX, etc, are not installed by default. In case a user tries to run tvmc using a model whose framework was not installed, it will be presented with a very raw Python exception in the output. The aim of this commit is to implement a better error messages for errors related to lazy-loading frontend frameworks in tvmc. Change-Id: Ida52fac4116af392ee436390e14ea02c7090cef0
…#9074) When installing TVM from the python package, the Frontend frameworks dependencies such as TensorFlow, PyTorch, ONNX, etc, are not installed by default. In case a user tries to run tvmc using a model whose framework was not installed, it will be presented with a very raw Python exception in the output. The aim of this commit is to implement a better error messages for errors related to lazy-loading frontend frameworks in tvmc. Change-Id: Ida52fac4116af392ee436390e14ea02c7090cef0
…#9074) When installing TVM from the python package, the Frontend frameworks dependencies such as TensorFlow, PyTorch, ONNX, etc, are not installed by default. In case a user tries to run tvmc using a model whose framework was not installed, it will be presented with a very raw Python exception in the output. The aim of this commit is to implement a better error messages for errors related to lazy-loading frontend frameworks in tvmc. Change-Id: Ida52fac4116af392ee436390e14ea02c7090cef0
…#9074) When installing TVM from the python package, the Frontend frameworks dependencies such as TensorFlow, PyTorch, ONNX, etc, are not installed by default. In case a user tries to run tvmc using a model whose framework was not installed, it will be presented with a very raw Python exception in the output. The aim of this commit is to implement a better error messages for errors related to lazy-loading frontend frameworks in tvmc. Change-Id: Ida52fac4116af392ee436390e14ea02c7090cef0
When installing TVM from the python package, the Frontend frameworks dependencies such as TensorFlow, PyTorch, ONNX, etc, are not installed by default.
In case a user tries to run tvmc using a model whose framework was not installed, it will be presented with a very raw Python exception in the output.
The aim of this commit is to implement a better error messages for errors related to lazy-loading frontend frameworks in tvmc.
cc @areusch @leandron @gromero @Mousius for reviews