Skip to content

Commit 3f95427

Browse files
lucas/onnx_gpu_backend (#24)
* Initial deep_ort_gpu plugin with internal library issues * Functioning onnxruntime with CUDA as execution provider * Removed requirement for cuda toolkit * cleaning up cmake * updating tests * parameterizing parameters that weren't actually parameters, updating tests in the process * addressing issues with IO binding, thread-loca caching bug (idk this one), unused members and hardcoded float types * launch tests for local use only * trying to get the tensorrt EP working * tensorrt tested to be working apparently, check deep_sample * debugging ci * testing --------- Co-authored-by: Eddy Zhou <edsteredward@gmail.com>
1 parent f68c5c6 commit 3f95427

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2232
-904
lines changed

.devcontainer/Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Multi-stage ROS2 development container (CPU/GPU compatible)
22
ARG ROS_DISTRO=humble
3-
ARG CUDA_VERSION=12.4.0
4-
ARG UBUNTU_VERSION=22.04
3+
ARG NVIDIA_CONTAINER_TAG=12.4.1-cudnn-runtime-ubuntu22.04
54

65
# ===============================================
76
# CPU Base - Standard ROS2 image
@@ -11,7 +10,7 @@ FROM ros:${ROS_DISTRO}-ros-base AS cpu-base
1110
# ===============================================
1211
# GPU Base - CUDA with manual ROS2 install
1312
# ===============================================
14-
FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION} AS gpu-base
13+
FROM nvidia/cuda:${NVIDIA_CONTAINER_TAG} AS gpu-base
1514
ARG ROS_DISTRO
1615
ARG TENSORRT_RUNTIME_VERSION
1716
ARG TENSORRT_CUDA_VERSION
@@ -39,16 +38,19 @@ ENV DEBIAN_FRONTEND=interactive
3938
RUN curl -fsSL -o cuda-keyring_1.1-1_all.deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb \
4039
&& dpkg -i cuda-keyring_1.1-1_all.deb \
4140
&& apt-get update && apt-get install -y --no-install-recommends \
42-
libnvinfer-lean10=${TENSORRT_RUNTIME_VERSION}-1+cuda${TENSORRT_CUDA_VERSION} \
41+
libnvinfer10=${TENSORRT_RUNTIME_VERSION}-1+cuda${TENSORRT_CUDA_VERSION} \
42+
libnvinfer-plugin10=${TENSORRT_RUNTIME_VERSION}-1+cuda${TENSORRT_CUDA_VERSION} \
43+
libnvonnxparsers10=${TENSORRT_RUNTIME_VERSION}-1+cuda${TENSORRT_CUDA_VERSION} \
4344
&& rm cuda-keyring_1.1-1_all.deb
4445

4546
# ===============================================
46-
# Install Common Development Tools from Either Base
47+
# Install Common Development Tools in Either Base
4748
# ===============================================
4849
FROM ${TARGETARCH:-cpu}-base AS dev-tools
4950

5051
# Install development tools not in base image
5152
RUN apt-get update && apt-get install -y --no-install-recommends \
53+
build-essential \
5254
python3-pip \
5355
python3-colcon-common-extensions \
5456
python3-rosdep \
@@ -70,7 +72,9 @@ FROM dev-tools AS source
7072

7173
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
7274
RUN --mount=type=bind,source=.,target=/tmp/src \
73-
apt-get -qq update && rosdep update && \
75+
apt-get -qq update && \
76+
rosdep init || true && \
77+
rosdep update && \
7478
rosdep install --from-paths /tmp/src --ignore-src -r -s \
7579
| (grep 'apt-get install' || true) \
7680
| awk '{print $3}' \

.devcontainer/generate_devcontainer.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
# limitations under the License.
1616
# generate_devcontainer.sh
1717
# Usage:
18-
# ./generate_devcontainer.sh <ros_distro> <container_type> [cuda_version] [ubuntu_version]
18+
# ./generate_devcontainer.sh <ros_distro> <container_type> [nvidia_container_tag]
1919

2020
set -e
2121

2222
ROS_DISTRO=${1:-humble}
2323
CONTAINER_TYPE=${2:-cpu}
24-
CUDA_VERSION=${3:-12.4.0}
25-
UBUNTU_VERSION=${4:-22.04}
24+
NVIDIA_CONTAINER_TAG=${3:-12.4.1-cudnn-runtime-ubuntu22.04}
2625
USERNAME=${USER:-vscode}
2726

2827
# TensorRT configuration
@@ -35,8 +34,7 @@ echo "ROS Distribution: $ROS_DISTRO"
3534
echo "Container Type: $CONTAINER_TYPE"
3635

3736
if [ "$CONTAINER_TYPE" = "gpu" ]; then
38-
echo "CUDA Version: $CUDA_VERSION"
39-
echo "Ubuntu Version: $UBUNTU_VERSION"
37+
echo "NVIDIA Container Tag: $NVIDIA_CONTAINER_TAG"
4038
echo "TensorRT Runtime Version: $TENSORRT_RUNTIME_VERSION"
4139
echo "TensorRT CUDA Version: $TENSORRT_CUDA_VERSION"
4240
fi
@@ -47,8 +45,7 @@ if [ "$CONTAINER_TYPE" = "gpu" ]; then
4745
BUILD_ARGS='"ROS_DISTRO": "'$ROS_DISTRO'",
4846
"USERNAME": "'$USERNAME'",
4947
"TARGETARCH": "gpu",
50-
"CUDA_VERSION": "'$CUDA_VERSION'",
51-
"UBUNTU_VERSION": "'$UBUNTU_VERSION'",
48+
"NVIDIA_CONTAINER_TAG": "'$NVIDIA_CONTAINER_TAG'",
5249
"TENSORRT_RUNTIME_VERSION": "'$TENSORRT_RUNTIME_VERSION'",
5350
"TENSORRT_CUDA_VERSION": "'$TENSORRT_CUDA_VERSION'",
5451
"USER_UID": "'$(id -u)'",

.github/actions/build-and-test/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ runs:
2929
shell: bash
3030
run: |
3131
source /opt/ros/${{ inputs.ros-distro }}/setup.bash
32-
colcon build --merge-install
32+
IS_CI=1 colcon build --merge-install
3333
3434
- name: ✅ Run tests
3535
shell: bash
3636
run: |
3737
source /opt/ros/${{ inputs.ros-distro }}/setup.bash
38-
colcon test --merge-install --event-handlers console_cohesion+
38+
IS_CI=1 colcon test --merge-install --event-handlers console_cohesion+
3939
colcon test-result --verbose
4040
4141
- name: 🗃️ Upload test logs as artifacts

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ log/
77
.devcontainer/devcontainer.json
88
.devcontainer/.env
99

10+
# Launch test cache
11+
__pycache__/
12+
1013
# Claude helpers
1114
.claude/
1215
CLAUDE.md

.vscode/tasks.json

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
"args": [
2828
"${input:rosDistro}",
2929
"gpu",
30-
"${input:cudaVersion}",
31-
"${input:ubuntuVersion}"
30+
"${input:nvidiaContainer}"
3231
],
3332
"problemMatcher": [],
3433
"group": "build",
@@ -72,41 +71,32 @@
7271
"default": "cpu"
7372
},
7473
{
75-
"id": "cudaVersion",
74+
"id": "nvidiaContainer",
7675
"type": "pickString",
77-
"description": "Select CUDA version",
76+
"description": "Select NVIDIA CUDA container (runtime + cuDNN, Ubuntu 20/22/24)",
7877
"options": [
79-
"12.8.0",
80-
"12.6.2",
81-
"12.5.1",
82-
"12.4.1",
83-
"12.4.0",
84-
"12.3.2",
85-
"12.2.2",
86-
"12.1.1",
87-
"12.0.1"
78+
"12.8.0-cudnn-runtime-ubuntu24.04",
79+
"12.8.0-cudnn-runtime-ubuntu22.04",
80+
"12.8.0-cudnn-runtime-ubuntu20.04",
81+
"12.6.2-cudnn-runtime-ubuntu24.04",
82+
"12.6.2-cudnn-runtime-ubuntu22.04",
83+
"12.6.2-cudnn-runtime-ubuntu20.04",
84+
"12.5.1-cudnn-runtime-ubuntu24.04",
85+
"12.5.1-cudnn-runtime-ubuntu22.04",
86+
"12.5.1-cudnn-runtime-ubuntu20.04",
87+
"12.4.1-cudnn-runtime-ubuntu24.04",
88+
"12.4.1-cudnn-runtime-ubuntu22.04",
89+
"12.4.1-cudnn-runtime-ubuntu20.04",
90+
"12.3.2-cudnn-runtime-ubuntu22.04",
91+
"12.3.2-cudnn-runtime-ubuntu20.04",
92+
"12.2.2-cudnn8-runtime-ubuntu22.04",
93+
"12.2.2-cudnn8-runtime-ubuntu20.04",
94+
"12.1.1-cudnn8-runtime-ubuntu22.04",
95+
"12.1.1-cudnn8-runtime-ubuntu20.04",
96+
"12.0.1-cudnn8-runtime-ubuntu22.04",
97+
"12.0.1-cudnn8-runtime-ubuntu20.04"
8898
],
89-
"default": "12.4.0"
90-
},
91-
{
92-
"id": "ubuntuVersion",
93-
"type": "pickString",
94-
"description": "Select Ubuntu version",
95-
"options": [
96-
{
97-
"label": "Ubuntu 24.04 (Noble)",
98-
"value": "24.04"
99-
},
100-
{
101-
"label": "Ubuntu 22.04 (Jammy)",
102-
"value": "22.04"
103-
},
104-
{
105-
"label": "Ubuntu 20.04 (Focal)",
106-
"value": "20.04"
107-
}
108-
],
109-
"default": "22.04"
99+
"default": "12.4.1-cudnn-runtime-ubuntu22.04"
110100
}
111101
]
112102
}

DEVELOPING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,37 @@ This project includes VS Code dev container configurations for easy ROS2 develop
2929
### Common Commands
3030

3131
Inside the container, you can do ros2 commands, colcon commands, rosdep, etc.
32+
33+
## Testing
34+
35+
### CI Testing (CPU Only)
36+
37+
```bash
38+
export IS_CI=1
39+
colcon build
40+
source install/setup.bash && colcon test
41+
colcon test-result --verbose
42+
```
43+
44+
GPU backends are automatically skipped when `IS_CI=1`.
45+
46+
### Local GPU Testing
47+
48+
**Requires**: NVIDIA container with GPU access (Runtime Libraries and CuDNN)
49+
Testing with GPU can be done using one of the support GPU devcontainers.
50+
51+
```bash
52+
export IS_CI=0 # or unset IS_CI
53+
colcon build
54+
source install/setup.bash && colcon test
55+
colcon test-result --verbose
56+
```
57+
58+
### Testing Philosophy
59+
60+
Given that access to GPU runners are limited, we settled on a testing procedure to test GPU-related software locally. The codebase is designed such that **if a backend works with `deep_sample`, it works everywhere.**
61+
62+
- CPU backends: Tested in CI automatically
63+
- GPU backends: Must be tested locally with GPU before release
64+
- `deep_sample` validates all backend plugins end-to-end
65+
- Other packages tested with CPU only in CI

deep_core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ target_include_directories(${DEEP_CORE_LIB} PUBLIC
4747
target_link_libraries(${DEEP_CORE_LIB}
4848
PUBLIC
4949
pluginlib::pluginlib
50-
PRIVATE
5150
rclcpp::rclcpp
5251
rclcpp_lifecycle::rclcpp_lifecycle
52+
PRIVATE
5353
bondcpp::bondcpp
5454
)
5555

deep_core/include/deep_core/plugin_interfaces/backend_inference_executor.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <string>
2020
#include <vector>
2121

22+
#include <rclcpp/rclcpp.hpp>
23+
2224
#include "deep_core/types/tensor.hpp"
2325

2426
namespace deep_ros

deep_core/include/deep_core/plugin_interfaces/backend_memory_allocator.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <string>
1919
#include <vector>
2020

21+
#include <rclcpp/rclcpp.hpp>
22+
2123
namespace deep_ros
2224
{
2325

deep_core/include/deep_core/plugin_interfaces/deep_backend_plugin.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include <memory>
1818
#include <string>
1919

20+
#include <rclcpp/rclcpp.hpp>
21+
#include <rclcpp_lifecycle/lifecycle_node.hpp>
22+
2023
#include "deep_core/plugin_interfaces/backend_inference_executor.hpp"
2124
#include "deep_core/plugin_interfaces/backend_memory_allocator.hpp"
2225

@@ -34,6 +37,12 @@ class DeepBackendPlugin
3437
public:
3538
virtual ~DeepBackendPlugin() = default;
3639

40+
/**
41+
* @brief Initialize plugin with node instance to enable parameter loading
42+
* @param node Shared pointer to the lifecycle node instance
43+
*/
44+
virtual void initialize(rclcpp_lifecycle::LifecycleNode::SharedPtr node) = 0;
45+
3746
/**
3847
* @brief Get the backend name
3948
* @return Backend name (e.g., "onnxruntime", "tensorrt")

0 commit comments

Comments
 (0)