Skip to content

Commit

Permalink
Merge pull request #55 from Ar-Ray-code/feat/jazzy
Browse files Browse the repository at this point in the history
support ubuntu24 (but there is not tested)
  • Loading branch information
Ar-Ray-code authored Sep 23, 2024
2 parents 612f82f + ab58ecd commit 0e2b5cd
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 125 deletions.
15 changes: 7 additions & 8 deletions yolox_ros_cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## Requirements
- ROS2 Iron
- ros-iron-generate-parameter-library
- ros-iron-vision-msgs
- ros-iron-usb-cam
- ros-jazzy-generate-parameter-library
- ros-jazzy-vision-msgs
- ros-jazzy-usb-cam
- OpenCV 4.x
- OpenVINO 2024.*
- TensorRT 10.x *
Expand All @@ -23,7 +23,7 @@
## Clone YOLOX-ROS
```bash
cd ~/ros2_ws/src
git clone --recursive https://github.com/Ar-Ray-code/YOLOX-ROS -b iron
git clone --recursive https://github.com/Ar-Ray-code/YOLOX-ROS -b jazzy
```

## Model Convert or Download
Expand Down Expand Up @@ -75,16 +75,15 @@ cd ~/ros2_ws

```bash
# build with openvino
source /opt/ros/humble/setup.bash
source /opt/intel/openvino_2021/bin/setupvars.sh
source /opt/ros/jazzy/setup.bash
colcon build --symlink-install --cmake-args -DYOLOX_USE_OPENVINO=ON
```

### TensorRT

```bash
# build with tensorrt
source /opt/ros/iron/setup.bash
source /opt/ros/jazzy/setup.bash
colcon build --symlink-install --cmake-args -DYOLOX_USE_TENSORRT=ON
```

Expand All @@ -95,7 +94,7 @@ colcon build --symlink-install --cmake-args -DYOLOX_USE_TENSORRT=ON
https://www.tensorflow.org/lite/guide/build_cmake

Below is an example build script.
Please change `${WORKSPACE}` as appropriate for your environment.
Please change `${WORKSPACE}` as appropriate for your envjazzyment.
```bash
export WORKSPACE=${HOME}/ws_tflite
mkdir -p ${WORKSPACE}
Expand Down
17 changes: 12 additions & 5 deletions yolox_ros_cpp/docker/onnxruntime/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,24 @@ services:
build:
context: .
args:
- BASE_TAB=12.1.0-cudnn8-devel-ubuntu22.04
image: fateshelled/onnxruntime_yolox_ros:latest
- BASE_TAB=12.6.1-cudnn-devel-ubuntu24.04
network_mode: host
runtime: nvidia
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]

environment:
- DISPLAY=$DISPLAY
- NVIDIA_DISABLE_REQUIRE=1
volumes:
- $HOME/ros2_ws:/root/ros2_ws
- /tmp/.X11-unix:/tmp/.X11-unix
devices:
- "/dev/video0:/dev/video0"
# devices:
# - "/dev/video0:/dev/video0"
working_dir: /root/ros2_ws
tty: true
command: bash
Expand Down
69 changes: 26 additions & 43 deletions yolox_ros_cpp/docker/onnxruntime/dockerfile
Original file line number Diff line number Diff line change
@@ -1,63 +1,46 @@
ARG BASE_TAG=11.7.1-cudnn8-devel-ubuntu22.04
FROM nvcr.io/nvidia/cuda:${BASE_TAG}
ENV DEBIAN_FRONTEND=noninteractive
ARG BASE_TAG=12.6.1-cudnn-devel-ubuntu24.04
FROM nvidia/cuda:${BASE_TAG}

ENV TZ=Asia/Tokyo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENV DEBIAN_FRONTEND=noninteractive

ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
RUN apt update && \
apt install -y python3-dev python3-pip \
ca-certificates g++ gcc make git aria2 && \

RUN apt update && apt install -y locales git cmake wget curl gnupg2 lsb-release python3-numpy python3-setuptools python3-wheel && \
locale-gen en_US en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
apt -y clean && \
rm -rf /var/lib/apt/lists/* && \
aria2c -q -d /tmp -o cmake-3.21.0-linux-x86_64.tar.gz https://github.com/Kitware/CMake/releases/download/v3.21.0/cmake-3.21.0-linux-x86_64.tar.gz && \
tar -zxf /tmp/cmake-3.21.0-linux-x86_64.tar.gz --strip=1 -C /usr
RUN python3 -m pip install -U pip && \
python3 -m pip install -U numpy setuptools wheel && \
python3 -m pip cache purge
rm -rf /var/lib/apt/lists/*
ENV LANG=en_US.UTF-8

WORKDIR /workdir
RUN git clone --depth 1 --recursive https://github.com/microsoft/onnxruntime -b v1.12.1 && \
RUN git clone --depth 1 --recursive https://github.com/microsoft/onnxruntime -b v1.19.2 && \
cd onnxruntime && \
./build.sh --cudnn_home /usr/lib/x86_64-linux-gnu/ \
--cuda_home /usr/local/cuda \
--use_cuda \
--config RelWithDebInfo \
--build_shared_lib \
--allow_running_as_root \
--skip_tests && \
cd build/Linux/RelWithDebInfo && \
make install && \
rm -r /workdir/onnxruntime

# Install ROS2
RUN apt update && apt install locales && \
locale-gen en_US en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
apt -y clean && \
rm -rf /var/lib/apt/lists/*
ENV LANG=en_US.UTF-8
make install

RUN apt update && \
apt install -y git wget curl gnupg2 lsb-release && \
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null && \
sed -i -e 's/ubuntu .* main/ubuntu jammy main/g' /etc/apt/sources.list.d/ros2.list && \
sed -i -e 's/ubuntu .* main/ubuntu noble main/g' /etc/apt/sources.list.d/ros2.list && \
apt update && \
apt install -y ros-dev-tools \
ros-humble-cv-bridge \
ros-humble-generate-parameter-library \
ros-humble-parameter-traits \
ros-humble-ros-base \
ros-humble-rqt-image-view \
ros-humble-v4l2-camera && \
ros-jazzy-cv-bridge \
ros-jazzy-generate-parameter-library \
ros-jazzy-parameter-traits \
ros-jazzy-ros-base \
ros-jazzy-rqt-image-view \
ros-jazzy-usb-cam \
ros-jazzy-vision-msgs && \
apt -y clean && \
rm -rf /var/lib/apt/lists/* && \
pip install -U pip && \
pip install catkin_pkg && \
pip install empy && \
pip install lark && \
python3 -m pip cache purge

rm -rf /var/lib/apt/lists/*

WORKDIR /workspace
COPY ./ros_entrypoint.sh /ros_entrypoint.sh
RUN echo "source /ros_entrypoint.sh" >> /root/.bashrc
# ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]
3 changes: 1 addition & 2 deletions yolox_ros_cpp/docker/onnxruntime/ros_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/bash
source /opt/ros/humble/setup.bash
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash
source /opt/ros/jazzy/setup.bash
7 changes: 3 additions & 4 deletions yolox_ros_cpp/docker/openvino/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ services:
environment:
- DISPLAY=$DISPLAY
volumes:
- ../../../:/root/ros2_ws/src
- $HOME/ros2_ws:/root/ros2_ws
- /tmp/.X11-unix:/tmp/.X11-unix
devices:
- "/dev/video0:/dev/video0"
# devices:
# - "/dev/video0:/dev/video0"
working_dir: /root/ros2_ws
tty: true
command: bash

23 changes: 10 additions & 13 deletions yolox_ros_cpp/docker/openvino/dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.04
FROM ubuntu:24.04

ENV TZ=Asia/Tokyo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
Expand All @@ -16,30 +16,27 @@ ENV LANG=en_US.UTF-8
RUN apt update && \
apt install -y git wget curl gnupg2 lsb-release

# ROS
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null && \
sed -i -e 's/ubuntu .* main/ubuntu jammy main/g' /etc/apt/sources.list.d/ros2.list
sed -i -e 's/ubuntu .* main/ubuntu noble main/g' /etc/apt/sources.list.d/ros2.list
# INTEL OPENVINO
RUN wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && \
apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && \
echo "deb https://apt.repos.intel.com/openvino/2024 ubuntu22 main" | tee /etc/apt/sources.list.d/intel-openvino-2024.list
echo "deb https://apt.repos.intel.com/openvino/2024 ubuntu24 main" | tee /etc/apt/sources.list.d/intel-openvino-2024.list

# install ros and openvino
RUN apt update && \
apt install -y openvino-2024.2.0 \
ros-dev-tools \
ros-humble-cv-bridge \
ros-humble-generate-parameter-library \
ros-humble-parameter-traits \
ros-humble-ros-base \
ros-humble-rqt-image-view \
ros-humble-v4l2-camera && \
ros-jazzy-cv-bridge \
ros-jazzy-generate-parameter-library \
ros-jazzy-parameter-traits \
ros-jazzy-ros-base \
ros-jazzy-rqt-image-view \
ros-jazzy-usb-cam \
ros-jazzy-vision-msgs && \
apt -y clean && \
rm -rf /var/lib/apt/lists/*

WORKDIR /workspace
COPY ./ros_entrypoint.sh /ros_entrypoint.sh
RUN echo "source /ros_entrypoint.sh" >> /root/.bashrc
# RUN echo "source /opt/intel/openvino/bin/setupvars.sh " >> /root/.bashrc
CMD ["bash"]
4 changes: 1 addition & 3 deletions yolox_ros_cpp/docker/openvino/ros_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#!/bin/bash
source /opt/ros/humble/setup.bash
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash

source /opt/ros/jazzy/setup.bash
18 changes: 12 additions & 6 deletions yolox_ros_cpp/docker/tensorrt/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@ services:
build:
context: .
args:
- TENSORRT_VERSION=10.1
- CUDNN_VERSION=9.2
- PYTHON_VERSION=3.10
- TENSORRT_VERSION=12.6
- PYTHON_VERSION=3.12
network_mode: host
runtime: nvidia
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
environment:
- DISPLAY=$DISPLAY
- NVIDIA_DISABLE_REQUIRE=1
volumes:
- $HOME/ros2_ws:/root/ros2_ws
- /tmp/.X11-unix:/tmp/.X11-unix
devices:
- "/dev/video0:/dev/video0"
# devices:
# - "/dev/video0:/dev/video0"
working_dir: /root/ros2_ws
tty: true
command: bash
53 changes: 17 additions & 36 deletions yolox_ros_cpp/docker/tensorrt/dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# pytorch/TensorRT/docker/Dockerfile
# Base image starts with CUDA
ARG BASE_IMG=nvidia/cuda:12.4.1-devel-ubuntu22.04
ARG BASE_IMG=nvidia/cuda:12.6.1-devel-ubuntu24.04
FROM ${BASE_IMG} as base
ENV BASE_IMG=nvidia/cuda:12.4.1-devel-ubuntu22.04
ENV BASE_IMG=nvidia/cuda:12.6.1-devel-ubuntu24.04

ARG TENSORRT_VERSION
ENV TENSORRT_VERSION=${TENSORRT_VERSION}
Expand All @@ -17,28 +17,14 @@ ENV DEBIAN_FRONTEND=noninteractive

# Install basic dependencies
RUN apt-get update
RUN apt install -y build-essential manpages-dev wget zlib1g software-properties-common git libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget ca-certificates curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev mecab-ipadic-utf8

# Install PyEnv and desired Python version
ENV HOME="/root"
ENV PYENV_DIR="$HOME/.pyenv"
ENV PATH="$PYENV_DIR/shims:$PYENV_DIR/bin:$PATH"
RUN wget -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer &&\
chmod 755 pyenv-installer &&\
bash pyenv-installer &&\
eval "$(pyenv init -)"

RUN pyenv install -v ${PYTHON_VERSION}
RUN pyenv global ${PYTHON_VERSION}
RUN apt install -y build-essential manpages-dev wget zlib1g software-properties-common git libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev ca-certificates curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev mecab-ipadic-utf8

# Install TensorRT + dependencies
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub
RUN add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /"
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/3bf863cc.pub
RUN add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/ /"
RUN apt-get update
RUN TENSORRT_MAJOR_VERSION=`echo ${TENSORRT_VERSION} | cut -d '.' -f 1` && apt-get install -y tensorrt

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install locales && \
locale-gen en_US en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
Expand All @@ -47,27 +33,22 @@ RUN apt update && apt install locales && \
ENV LANG=en_US.UTF-8

RUN apt update && \
apt install -y git wget curl gnupg2 lsb-release && \
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \
apt install -y git wget curl gnupg2 lsb-release

RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null && \
sed -i -e 's/ubuntu .* main/ubuntu jammy main/g' /etc/apt/sources.list.d/ros2.list && \
sed -i -e 's/ubuntu .* main/ubuntu noble main/g' /etc/apt/sources.list.d/ros2.list && \
apt update && \
apt install -y ros-dev-tools \
ros-humble-cv-bridge \
ros-humble-generate-parameter-library \
ros-humble-parameter-traits \
ros-humble-ros-base \
ros-humble-rqt-image-view \
ros-humble-v4l2-camera && \
ros-jazzy-cv-bridge \
ros-jazzy-generate-parameter-library \
ros-jazzy-parameter-traits \
ros-jazzy-ros-base \
ros-jazzy-rqt-image-view \
ros-jazzy-usb-cam \
ros-jazzy-vision-msgs && \
apt -y clean && \
rm -rf /var/lib/apt/lists/* && \
pip install -U pip && \
pip install catkin_pkg && \
pip install empy==3.3.4 && \
pip install lark && \
python3 -m pip cache purge
rm -rf /var/lib/apt/lists/*

COPY ./ros_entrypoint.sh /ros_entrypoint.sh
RUN echo "source /ros_entrypoint.sh" >> /root/.bashrc
# ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]
3 changes: 1 addition & 2 deletions yolox_ros_cpp/docker/tensorrt/ros_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/bash
source /opt/ros/humble/setup.bash
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash
source /opt/ros/jazzy/setup.bash
2 changes: 1 addition & 1 deletion yolox_ros_cpp/yolox_cpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>yolox_cpp</name>
<version>0.4.0</version>
<version>0.4.1</version>
<description>The yolox_cpp package</description>
<maintainer email="[email protected]">fateshelled</maintainer>
<license>Apache-2.0 License</license>
Expand Down
2 changes: 1 addition & 1 deletion yolox_ros_cpp/yolox_param/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>yolox_param</name>
<version>0.4.0</version>
<version>0.4.1</version>
<description>YOLOX-ROS Parameter Package</description>
<maintainer email="[email protected]">Ar-Ray-code</maintainer>
<license>Apache-2.0</license>
Expand Down
2 changes: 1 addition & 1 deletion yolox_ros_cpp/yolox_ros_cpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>yolox_ros_cpp</name>
<version>0.4.0</version>
<version>0.4.1</version>
<description>The yolox_ros_cpp package</description>
<maintainer email="[email protected]">fateshelled</maintainer>
<license>Apache-2.0 License</license>
Expand Down

0 comments on commit 0e2b5cd

Please sign in to comment.