mmdeploy icon indicating copy to clipboard operation
mmdeploy copied to clipboard

About the bug caused by the file name of profile.py

Open Talnex opened this issue 2 years ago • 4 comments

HiHi When I deployed, I found that the numba library would be imported when using mmdeploy/tools/deploy.py for model conversion and got ''AttributeError: module 'profile' has no attribute 'run' ''

After a lot of trying, I found that this bug can be avoided by just changing the name of mmdeploy/tools/profile.py

This is because profile.py in this directory will be mistakenly considered as part of itself when importing numba. I suggest changing the name of this file to 'profiler.py'

I don't know if this is a bug because I didn't find anyone asking this question in issues, just write it here If someone encounters the same problem, they may find the answer here.

Just import numba in the mmdeploy/tools directory to reproduce the bug like this:

(mm) jetson@jetson-desktop:~/mmdeploy/tools$ python
Python 3.6.15 | packaged by conda-forge | (default, Dec  3 2021, 19:12:04)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jetson/archiconda3/envs/mm/lib/python3.6/site-packages/numba/__init__.py", line 20, in <module>
    from numba.testing import _runtests as runtests
  File "/home/jetson/archiconda3/envs/mm/lib/python3.6/site-packages/numba/testing/__init__.py", line 9, in <module>
    from .main import NumbaTestProgram, SerialSuite, make_tag_decorator
  File "/home/jetson/archiconda3/envs/mm/lib/python3.6/site-packages/numba/testing/main.py", line 3, in <module>
    import cProfile
  File "/home/jetson/archiconda3/envs/mm/lib/python3.6/cProfile.py", line 22, in <module>
    run.__doc__ = _pyprofile.run.__doc__
AttributeError: module 'profile' has no attribute 'run'

Talnex avatar Jul 26 '22 15:07 Talnex

@Talnex Hi, thanks for your feed back. Normally, users would call python tools/profile.py and does not go to the tools directory. However, if it's necessary, you could give us a PR to rename the file and update the docs.

RunningLeon avatar Jul 27 '22 01:07 RunningLeon

@Talnex Hi, thanks for your feed back. Normally, users would call python tools/profile.py and does not go to the tools directory. However, if it's necessary, you could give us a PR to rename the file and update the docs.

It's not a solution, when I run python tools/deploy.py ......., the error occures again. After rename profile.py to toolprofile.py, it works.

bladrome avatar Jul 28 '22 03:07 bladrome

@Talnex Hi, thanks for your feed back. Normally, users would call python tools/profile.py and does not go to the tools directory. However, if it's necessary, you could give us a PR to rename the file and update the docs.

It's not a solution, when I run python tools/deploy.py ......., the error occures again. After rename profile.py to toolprofile.py, it works.

It may be that a package in your environment has a name conflict with profiler.py, so this file should be changed to another name to ensure that there will be no conflict

Talnex avatar Jul 30 '22 07:07 Talnex

@Talnex Hi, thanks for your feed back. Normally, users would call python tools/profile.py and does not go to the tools directory. However, if it's necessary, you could give us a PR to rename the file and update the docs.

Sorry for the late reply, it seems that I am not the only one with this problem, I will study how to submit PR

Talnex avatar Jul 30 '22 07:07 Talnex