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

[Refactor][tools] Add prebuild tools. #347

Merged
merged 32 commits into from
May 23, 2022

Conversation

grimoire
Copy link
Member

@grimoire grimoire commented Apr 14, 2022

This PR provides tools to build prebuilt tools. Some other files are also modified to support the pre-build packaging.
Has been tested on linux-x64, both PC and jetson. TesnorRT on both platform and ONNXRuntime on PC.
Usage:

python ${MMDEPLOY_DIR}/tools/package_tools/mmdeploy_builder.py \
    ${MMDEPLOY_DIR}/tools/package_tools/configs/linux_x86_trt.yaml \
    ${MMDEPLOY_DIR}

You might need to edit your own config file to build a different package.
Windows package can also be built, but it has not been tested.

@grimoire grimoire mentioned this pull request Apr 15, 2022
@codecov
Copy link

codecov bot commented Apr 15, 2022

Codecov Report

Merging #347 (f00fe81) into dev-v0.5.0 (81a9719) will increase coverage by 3.29%.
The diff coverage is 33.33%.

❗ Current head f00fe81 differs from pull request most recent head 2edc101. Consider uploading reports for the commit 2edc101 to get more accurate results

@@              Coverage Diff               @@
##           dev-v0.5.0     #347      +/-   ##
==============================================
+ Coverage       59.18%   62.47%   +3.29%     
==============================================
  Files             233      221      -12     
  Lines            7739     7366     -373     
  Branches         1186     1136      -50     
==============================================
+ Hits             4580     4602      +22     
+ Misses           2835     2434     -401     
- Partials          324      330       +6     
Flag Coverage Δ
unittests 62.47% <33.33%> (+3.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmdeploy/backend/ncnn/__init__.py 47.05% <0.00%> (-10.09%) ⬇️
mmdeploy/backend/onnxruntime/init_plugins.py 100.00% <ø> (ø)
mmdeploy/backend/tensorrt/calib_utils.py 0.00% <0.00%> (ø)
mmdeploy/backend/tensorrt/init_plugins.py 31.25% <ø> (ø)
mmdeploy/backend/tensorrt/utils.py 0.00% <0.00%> (ø)
mmdeploy/backend/tensorrt/wrapper.py 0.00% <0.00%> (ø)
mmdeploy/backend/sdk/__init__.py 55.00% <14.28%> (-3.83%) ⬇️
mmdeploy/backend/tensorrt/__init__.py 37.50% <16.66%> (-16.35%) ⬇️
mmdeploy/__init__.py 45.45% <25.00%> (-17.05%) ⬇️
mmdeploy/backend/__init__.py 44.44% <28.57%> (+0.44%) ⬆️
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f59b44...2edc101. Read the comment docs.

@grimoire
Copy link
Member Author

Remove dependency in mmdeploy/codebase is not necessary. Since all these codebase reqire MMCV.

@grimoire grimoire changed the title [WIP]fix for pre-build [Refactor] fix for pre-build May 2, 2022
@grimoire grimoire changed the base branch from master to dev-v0.5.0 May 2, 2022 08:20
@grimoire
Copy link
Member Author

grimoire commented May 2, 2022

Note that new api might require some features from this PR.

import os
old_cuda_device = os.environ.get('CUDA_DEVICE', None)
os.environ['CUDA_DEVICE'] = str(device_id)
import pycuda.autoinit # noqa:F401
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may add pycuda to requirements

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I tested on Jetson, I only install successful with pycuda==2019.1. I haven't look up why yet.
I suggest we do not using lastest version of pycuda, we can set it to 2019.1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found that pycuda has been released not so often. Have you tried version of 2021.1?

@grimoire grimoire changed the title [Refactor] fix for pre-build [Refactor][tools] Add prebuild tools. May 5, 2022
@grimoire
Copy link
Member Author

grimoire commented May 5, 2022

The builder has been moved here.

@grimoire grimoire requested a review from irexyc May 5, 2022 09:43
@PeterH0323 PeterH0323 mentioned this pull request May 8, 2022
3 tasks
@RunningLeon
Copy link
Collaborator

Tested fine with trt in my linux.

Me too.

@lvhan028
Copy link
Collaborator

lvhan028 commented May 16, 2022

Have you had any idea about the package naming rules?

Nope. Should we use different package names for the different backend?

I am afraid the package will explode if we put backend as a part of the package name.
Here is my proposal:
mmdeploy-{os tag}-{cpu arch}-{device}?-version.{file extension}
e.g.,

  • mmdeploy-linux-x86_64-gpu-0.5.0.tar.gz
  • mmdeploy-windows-x86_64-0.5.0.zip

@lvhan028
Copy link
Collaborator

Mode LastWriteTime Length Name
d----- 5/17/2022 11:48 AM .mmdeploy_python
d----- 5/17/2022 11:48 AM dist
d----- 5/17/2022 11:48 AM sdk

In windows, after running the prebuild scripts, a .mmdeploy_python is generated. Is it necessary? What is it used for?

@grimoire
Copy link
Member Author

grimoire commented May 17, 2022

Mode LastWriteTime Length Name
d----- 5/17/2022 11:48 AM .mmdeploy_python
d----- 5/17/2022 11:48 AM dist
d----- 5/17/2022 11:48 AM sdk
In windows, after running the prebuild scripts, a .mmdeploy_python is generated. Is it necessary? What is it used for?

It is a copy of tools/package_tools/packaging. We need these codes to build mmdeploy_python wheel.
Should I remove it after packaging?

@lvhan028
Copy link
Collaborator

Mode LastWriteTime Length Name
d----- 5/17/2022 11:48 AM .mmdeploy_python
d----- 5/17/2022 11:48 AM dist
d----- 5/17/2022 11:48 AM sdk
In windows, after running the prebuild scripts, a .mmdeploy_python is generated. Is it necessary? What is it used for?

It is a copy of tools/package_tools/packaging. We need these codes to build mmdeploy_python wheel. Should I remove it after packaging?

If they are not necessary for our users, I think we can remove it safely.

lvhan028
lvhan028 previously approved these changes May 21, 2022
@grimoire grimoire requested review from lvhan028 and irexyc May 23, 2022 03:51
@irexyc irexyc self-requested a review May 23, 2022 09:11
@lvhan028 lvhan028 merged commit 4710ab9 into open-mmlab:dev-v0.5.0 May 23, 2022
lvhan028 pushed a commit to lvhan028/mmdeploy that referenced this pull request Jun 3, 2022
* move to lib

* optional import pytorch rewriter

* reduce torch dependancy of tensorrt export

* remove more mmcv support

* fix pytest

* remove mmcv logge

* Add `mmdeploy.utils.logging`

* Improve the common of the `get_logger`

* Fix lint

* onnxruntim add try catch to  import wrapper if pytorch is available

* Using `mmcv.utils.logging` in all files under `mmdeploy/codebase`

* add __init__

* add prebuild tools

* support windows

* for comment

* exit if failed

* add exist

* decouple

* add tags

* remove .mmdeploy_python

* read python version from system

* update windows config

* update linux config

* remote many

* better build name

* rename python tag

* fix pyhon-tag

* update window config

* add env search

* update tag

* fix build without CUDA_TOOLKIT_ROOT_DIR

Co-authored-by: HinGwenWoong <[email protected]>
lvhan028 pushed a commit to lvhan028/mmdeploy that referenced this pull request Jun 3, 2022
* move to lib

* optional import pytorch rewriter

* reduce torch dependancy of tensorrt export

* remove more mmcv support

* fix pytest

* remove mmcv logge

* Add `mmdeploy.utils.logging`

* Improve the common of the `get_logger`

* Fix lint

* onnxruntim add try catch to  import wrapper if pytorch is available

* Using `mmcv.utils.logging` in all files under `mmdeploy/codebase`

* add __init__

* add prebuild tools

* support windows

* for comment

* exit if failed

* add exist

* decouple

* add tags

* remove .mmdeploy_python

* read python version from system

* update windows config

* update linux config

* remote many

* better build name

* rename python tag

* fix pyhon-tag

* update window config

* add env search

* update tag

* fix build without CUDA_TOOLKIT_ROOT_DIR

Co-authored-by: HinGwenWoong <[email protected]>
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

Successfully merging this pull request may close these issues.

6 participants