ros-industrial / easy_perception_deployment

A ROS2 package that accelerates the training and deployment of CV models for industries.
Apache License 2.0
53 stars 16 forks source link

Use vendor packages instead of local installation #60

Closed Briancbn closed 1 year ago

Briancbn commented 1 year ago

Signed-off-by: Chen Bainian chenbn@artc.a-star.edu.sg

Using epd_onnxruntime_vendor package instead of local installation of onnx runtime. (Please note that local installation is still compatible)

Vendor Package

epd_onnxruntime_vendor: https://github.com/Briancbn/epd_onnxruntime_vendor

Following how it was done in https://github.com/ros2/yaml_cpp_vendor

The vendor package uses ExternalProject_Add to make the onnxruntime dependencies, if it is not found locally.

When sourcing setup.bash of the vendor package, an additional script is called to include the newly added library in to the LD_LIBRARY_PATH to avoid runtime linking error.

When calling find_package(epd_onnxruntime_vendor) from another package (e.g. epd), the following cmake extra script will be called to first check for local installation. If there is no local installation, it will uses the binaries built within the vendor package.

Naming

Since onnxruntime_vendor already exist, but cannot be used for EPD due to version difference and only works with released binaries, this packages is named to be epd_onnxruntime_vendor instead.

How to use

Simply download the vendor repository and compiling it using colcon build. For GPU usage, an additional USE_CUDA variable is provided.

colcon build --cmake-args -DUSE_CUDA=ON

Make sure that the vendor package is sourced or in the same workspace before building the EPD pacakges.

Limitations

How to test

1.With local installtion setup using script

colcon build of the vendor package shouldn't take long and it should skip the building from source using ExternalProject_Add

  1. Without local installation

This might be easier to test in a clean docker, since I am not sure how to uninstall a locally installed onnxruntime. colcon build (CPU / GPU) should takes about 10min to complete.

In both cases, you can see the following warning when building both the vendor and epd packages.

Found onnxruntime in path ...

Verify if the path is correct.

Next Step

Please let me know if the following can be reproduced and is something that EPD would benefit. Additional actions:

cardboardcode commented 1 year ago

Hi @Briancbn, thanks for the contribution, particularly with your busy schedule. 😊

Will have a closer look at this thread this Saturday (7th Oct 2022).

Apologies for the late reply. For unknown reasons, GitHub did not notify me when this pull request was created. 😞

cardboardcode commented 1 year ago

@Briancbn Thank you for the contribution. Will have a look at them this Saturday (29th Oct 2022). 😄

cardboardcode commented 1 year ago

Signed-off-by: Chen Bainian chenbn@artc.a-star.edu.sg

Using epd_onnxruntime_vendor package instead of local installation of onnx runtime. (Please note that local installation is still compatible)

Vendor Package

epd_onnxruntime_vendor: https://github.com/Briancbn/epd_onnxruntime_vendor

Following how it was done in https://github.com/ros2/yaml_cpp_vendor

The vendor package uses ExternalProject_Add to make the onnxruntime dependencies, if it is not found locally.

When sourcing setup.bash of the vendor package, an additional script is called to include the newly added library in to the LD_LIBRARY_PATH to avoid runtime linking error.

When calling find_package(epd_onnxruntime_vendor) from another package (e.g. epd), the following cmake extra script will be called to first check for local installation. If there is no local installation, it will uses the binaries built within the vendor package.

Naming

Since onnxruntime_vendor already exist, but cannot be used for EPD due to version difference and only works with released binaries, this packages is named to be epd_onnxruntime_vendor instead.

How to use

Simply download the vendor repository and compiling it using colcon build. For GPU usage, an additional USE_CUDA variable is provided.

colcon build --cmake-args -DUSE_CUDA=ON

Make sure that the vendor package is sourced or in the same workspace before building the EPD pacakges.

Limitations

* version is hard set to `36dc057913f968566eaa1646cb5db41d8c5e7654`. ([ref](https://github.com/Briancbn/epd_onnxruntime_vendor/blob/0b7f34ac1cb2197032b596fbdc90210e3ce6f111/CMakeLists.txt#L51))

  * CMake variables has changed between the versions release subsequently and the current one used. Additional work is needed to work with the latest version.

* No Windows support. Not on priority, but it's doable.

* It takes 10min to build the package (5min just to download)

  * process can be monitored after appending `--event-handlers=console-direct+` to `colcon build` command

How to test

1.With local installtion setup using script

colcon build of the vendor package shouldn't take long and it should skip the building from source using ExternalProject_Add

2. Without local installation

This might be easier to test in a clean docker, since I am not sure how to uninstall a locally installed onnxruntime. colcon build (CPU / GPU) should takes about 10min to complete.

In both cases, you can see the following warning when building both the vendor and epd packages.

Found onnxruntime in path ...

Verify if the path is correct.

Next Step

Please let me know if the following can be reproduced and is something that EPD would benefit. Additional actions:

* [ ]  Update the setup script

* [x]  Update the tutorial

* [ ]  Update Dockerfile

* [x]  Update CI

* [ ]  Transfer the vendor package into ros-industrial Github Organization

* [ ]  Merge this PR and all the related PR

* [ ]  Release to rosdistro

@Briancbn Merged pull request. You are awesome.

Replied to the above enquiry on which features would EPD benefit from.