Skip to content

Conversation

@tehkillerbee
Copy link
Contributor

Hello,

Over the last couple of months, I have been working on a bash script for building and installing MMDeploy and prerequisites to ease the install procedure when we use MMDetection, MMDeploy tools. Maybe this script can serve as a starting point for an easier install procedure when building and installing MMDeploy from source.

Naturally, this script is a work in progress. There are probably parts that can be cleaned up - and maybe some dependencies are not needed to install anymore.

Let me know if there are any suggestions and ideas on how to integrate this script with the MMDeploy

Note:

  1. Only tested with "standard" python virtual environment, as I do not use Conda
  2. Only tested on linux
  3. Only supports TensorRT build at this point.
  4. The script should work on both x86_64 and aarch64 (jetson) platforms.

@codecov
Copy link

codecov bot commented Apr 24, 2022

Codecov Report

Merging #399 (56ff03b) into dev-v0.5.0 (2265217) will decrease coverage by 0.01%.
The diff coverage is 66.66%.

❗ Current head 56ff03b differs from pull request most recent head 178dfc2. Consider uploading reports for the commit 178dfc2 to get more accurate results

@@              Coverage Diff               @@
##           dev-v0.5.0     #399      +/-   ##
==============================================
- Coverage       62.62%   62.60%   -0.02%     
==============================================
  Files             219      220       +1     
  Lines            7291     7312      +21     
  Branches         1120     1126       +6     
==============================================
+ Hits             4566     4578      +12     
- Misses           2402     2410       +8     
- Partials          323      324       +1     
Flag Coverage Δ
unittests 62.60% <66.66%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
mmdeploy/core/rewriters/rewriter_utils.py 93.28% <ø> (ø)
...y/codebase/mmedit/deploy/super_resolution_model.py 77.77% <25.00%> (ø)
...oy/codebase/mmdet/deploy/object_detection_model.py 83.39% <100.00%> (ø)
mmdeploy/codebase/base/backend_model.py 46.93% <0.00%> (-3.07%) ⬇️
mmdeploy/codebase/mmdet/deploy/utils.py 86.20% <0.00%> (-0.89%) ⬇️
mmdeploy/pytorch/ops/__init__.py 100.00% <0.00%> (ø)
mmdeploy/pytorch/functions/__init__.py 100.00% <0.00%> (ø)
...eploy/codebase/mmdet/models/roi_heads/bbox_head.py 75.60% <0.00%> (ø)
...loy/codebase/mmdet/models/dense_heads/yolo_head.py 70.96% <0.00%> (ø)
... and 9 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 89204d1...178dfc2. Read the comment docs.

@grimoire grimoire requested review from grimoire and lvhan028 April 25, 2022 02:07
Copy link
Collaborator

@lvhan028 lvhan028 left a comment

Choose a reason for hiding this comment

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

First of all, I suggest changing the target branch of this PR to dev-v0.5.0. We would like to make this one a new feature of MMDeploy and announce it when releasing v0.5.0.

Copy link
Collaborator

@lvhan028 lvhan028 left a comment

Choose a reason for hiding this comment

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

It seems this script targets NVIDIA devices and Linux OS. So perhaps it can be renamed as build_linux_nvidia.sh or something like that.

@grimoire
Copy link
Member

The install script of anaconda provides some interactive operations to custom the build. For example:

Anaconda3 will now be installed into this location:
/home/MyHome/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/MyHome/anaconda3] >>> 

You can also silence install by adding some other flags. This seems like a good way to custom the build. What do you think @lvhan028 @tehkillerbee

@tehkillerbee
Copy link
Contributor Author

The install script of anaconda provides some interactive operations to custom the build. For example:

Anaconda3 will now be installed into this location:
/home/MyHome/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/MyHome/anaconda3] >>> 

You can also silence install by adding some other flags. This seems like a good way to custom the build. What do you think @lvhan028 @tehkillerbee

This sounds like a good idea for an interactive install procedure. The default options can then be used for an unattended install.

@lvhan028
Copy link
Collaborator

The install script of anaconda provides some interactive operations to custom the build. For example:

Anaconda3 will now be installed into this location:
/home/MyHome/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/MyHome/anaconda3] >>> 

You can also silence install by adding some other flags. This seems like a good way to custom the build. What do you think @lvhan028 @tehkillerbee

Sounds great

@tehkillerbee tehkillerbee changed the base branch from master to dev-v0.5.0 April 26, 2022 14:37
@tehkillerbee
Copy link
Contributor Author

I have updated the PR with most of the comments you both suggested. Whats left is to make the install more interactive and also make it unattended. @lvhan028 @grimoire

@grimoire
Copy link
Member

grimoire commented May 1, 2022

Hi, could you drop the unrelated commit (which comes from master branch).

@tehkillerbee
Copy link
Contributor Author

Hi, could you drop the unrelated commit (which comes from master branch).

I tried to cherry pick the related commits and apply them to the dev v0.5.0 instead. Does it look OK to you?

@tehkillerbee
Copy link
Contributor Author

The install script of anaconda provides some interactive operations to custom the build. For example:

Anaconda3 will now be installed into this location:
/home/MyHome/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/MyHome/anaconda3] >>> 

You can also silence install by adding some other flags. This seems like a good way to custom the build. What do you think

@grimoire Regarding interactive install, should I just attempt to replicate the behaviour used by the anaconda installer or is there a install script I can use as a base?

@grimoire
Copy link
Member

grimoire commented May 2, 2022

We do not have a base script, it is ok to replicate the behavior of anaconda or you can design your own pattern.

@grimoire
Copy link
Member

grimoire commented May 3, 2022

I tried to cherry pick the related commits and apply them to the dev v0.5.0 instead. Does it look OK to you?

You can rebase -i and drop the commit from master(if they are not required for the build script).

@lvhan028
Copy link
Collaborator

lvhan028 commented May 7, 2022

Hi, @tehkillerbee. I think you can work on dev-v0.5.0 branch since there are lots of unrelated commits from master.

Johannes Linde added 5 commits May 9, 2022 08:00
* Auto detect installed version of cmake, gcc. Update if necessary
* Prompt to reinstall venv if exists
* Disable .tar packing
* Enable MMDEPLOY SDK Python
* Misc cleanup
@lvhan028
Copy link
Collaborator

@lvhan028 I am going to add silent mode as part of the interactive install. I.e. if the script is executed with a silent argument, it will use the default selections for all prompts.

Will it be OK to use the default selections or will it be necessary to override them somehow?

Using the default selections is fine. Thanks a lot

@lvhan028
Copy link
Collaborator

lvhan028 commented May 17, 2022

Hi, @tehkillerbee can you provide a build method?
Here is what I do in my conda environment:

git clone --recursive https://github.com/open-mmlab/mmdeploy.git
cd mmdeploy
./build_linux_nvidia.sh mmdeploy

But I got failures like,

Build and install 'mmdeploy'...
cat: MMDeploy/mmdeploy/version.py: No such file or directory
./build_linux_nvidia.sh: line 314: /home/PJLAB/lvhan/Documents/projects/open-mmlab/mmdeploy/venv-mmdeploy/bin/activate: No such file or directory

@tehkillerbee
Copy link
Contributor Author

tehkillerbee commented May 17, 2022

Hi, @tehkillerbee can you provide a build method? Here is what I do in my conda environment:

git clone --recursive https://github.com/open-mmlab/mmdeploy.git
cd mmdeploy
./build_linux_nvidia.sh mmdeploy

But I got failures like,

Build and install 'mmdeploy'...
cat: MMDeploy/mmdeploy/version.py: No such file or directory
./build_linux_nvidia.sh: line 314: /home/PJLAB/lvhan/Documents/projects/open-mmlab/mmdeploy/venv-mmdeploy/bin/activate: No such file or directory

Hi, @tehkillerbee can you provide a build method? Here is what I do in my conda environment:

git clone --recursive https://github.com/open-mmlab/mmdeploy.git
cd mmdeploy
./build_linux_nvidia.sh mmdeploy

But I got failures like,

Build and install 'mmdeploy'...
cat: MMDeploy/mmdeploy/version.py: No such file or directory
./build_linux_nvidia.sh: line 314: /home/PJLAB/lvhan/Documents/projects/open-mmlab/mmdeploy/venv-mmdeploy/bin/activate: No such file or directory

I think that is related to the issue mentioned by @grimoire. Initially my script assumed that a MMDeploy folder is found in the root directory. But since the root dir is now MMDeploy, there are some paths that are now incorrect. I will fix it now!

* Make prebuild archive optional.
* Add venv* to gitignore
@tehkillerbee
Copy link
Contributor Author

@lvhan028 The script can now run as unattended/auto but it is not strictly silent. Instead, all user interaction is skipped.

The default options might need to be changed to something more suitable.

You should be able to run it in this way:

./build_linux_nvidia.sh mmdeploy auto

@grimoire
Copy link
Member

Good to me. Any advice @lvhan028

@lvhan028
Copy link
Collaborator

Can we put this script to tools/scripts/?

Johannes Linde added 2 commits May 23, 2022 12:59
* Mention default option when reinstalling venv
* sudo make install instead of cmake --install
@tehkillerbee
Copy link
Contributor Author

@lvhan028 Updated PR according to your comments

Copy link
Member

@grimoire grimoire left a comment

Choose a reason for hiding this comment

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

LGTM

@grimoire grimoire merged commit 651eec2 into open-mmlab:dev-v0.5.0 May 25, 2022
lvhan028 pushed a commit to lvhan028/mmdeploy that referenced this pull request Jun 3, 2022
* Initial commit of build script

* Fixed lint

* * Set prefix depending on install arch
* Auto detect installed version of cmake, gcc. Update if necessary
* Prompt to reinstall venv if exists
* Disable .tar packing
* Enable MMDEPLOY SDK Python
* Misc cleanup

* Fixed lint

* Renamed script

* * Set env variables without restarting script.
* OpenCV install optional.
* Fix numpy OPENBLAS_CORETYPE on numpy >1.19.4.
* Remove specific build files.
* Fix prebuild output .tar.gz.
* Comments added. exec bash when closing script

* * Use root dir as MMDeploy dir.
* Use pip3.
* Remove explicit MMDeploy checkout version.
* Use MMDEPLOY_DIR for examples path

* Make PyTorch, torchvision, mmcv install optional

* * Do not deactivate python venv.
* Make prebuild archive optional.
* Add venv* to gitignore

* * Add support for unattended, interactive install. * Cleanup  misc. comments.

* Check input arguments before continuing.

* Added additional log messages, comments added

* Added default option when pressing [ENTER]

* * Rearranged cmake, gcc build/install order.
* Mention default option when reinstalling venv
* sudo make install instead of cmake --install

* Moved script to tools/scripts

* Fixed relative path when generating WORKING_DIR
lvhan028 pushed a commit to lvhan028/mmdeploy that referenced this pull request Jun 3, 2022
* Initial commit of build script

* Fixed lint

* * Set prefix depending on install arch
* Auto detect installed version of cmake, gcc. Update if necessary
* Prompt to reinstall venv if exists
* Disable .tar packing
* Enable MMDEPLOY SDK Python
* Misc cleanup

* Fixed lint

* Renamed script

* * Set env variables without restarting script.
* OpenCV install optional.
* Fix numpy OPENBLAS_CORETYPE on numpy >1.19.4.
* Remove specific build files.
* Fix prebuild output .tar.gz.
* Comments added. exec bash when closing script

* * Use root dir as MMDeploy dir.
* Use pip3.
* Remove explicit MMDeploy checkout version.
* Use MMDEPLOY_DIR for examples path

* Make PyTorch, torchvision, mmcv install optional

* * Do not deactivate python venv.
* Make prebuild archive optional.
* Add venv* to gitignore

* * Add support for unattended, interactive install. * Cleanup  misc. comments.

* Check input arguments before continuing.

* Added additional log messages, comments added

* Added default option when pressing [ENTER]

* * Rearranged cmake, gcc build/install order.
* Mention default option when reinstalling venv
* sudo make install instead of cmake --install

* Moved script to tools/scripts

* Fixed relative path when generating WORKING_DIR
ewernn pushed a commit to ewernn/mmdeploy that referenced this pull request Nov 17, 2025
* Initial commit of build script

* Fixed lint

* * Set prefix depending on install arch
* Auto detect installed version of cmake, gcc. Update if necessary
* Prompt to reinstall venv if exists
* Disable .tar packing
* Enable MMDEPLOY SDK Python
* Misc cleanup

* Fixed lint

* Renamed script

* * Set env variables without restarting script.
* OpenCV install optional.
* Fix numpy OPENBLAS_CORETYPE on numpy >1.19.4.
* Remove specific build files.
* Fix prebuild output .tar.gz.
* Comments added. exec bash when closing script

* * Use root dir as MMDeploy dir.
* Use pip3.
* Remove explicit MMDeploy checkout version.
* Use MMDEPLOY_DIR for examples path

* Make PyTorch, torchvision, mmcv install optional

* * Do not deactivate python venv.
* Make prebuild archive optional.
* Add venv* to gitignore

* * Add support for unattended, interactive install. * Cleanup  misc. comments.

* Check input arguments before continuing.

* Added additional log messages, comments added

* Added default option when pressing [ENTER]

* * Rearranged cmake, gcc build/install order.
* Mention default option when reinstalling venv
* sudo make install instead of cmake --install

* Moved script to tools/scripts

* Fixed relative path when generating WORKING_DIR
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.

3 participants