Skip to content

Commit

Permalink
modified for non-cuda case
Browse files Browse the repository at this point in the history
  • Loading branch information
xuhao1 committed Nov 29, 2024
1 parent 517e9dc commit d08c6d3
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 3 deletions.
1 change: 0 additions & 1 deletion d2frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ else()

target_link_libraries(loop_cnn
opencv_dnn
onnxruntime
opengv
)
endif()
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.arm64_ros1_noetic
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ WORKDIR $SWARM_WS
RUN source "/opt/ros/${ROS_VERSION}/setup.bash" && \
catkin config -DCMAKE_BUILD_TYPE=Release \
-DTorch_DIR=/usr/local/lib/python3.8/dist-packages/torch/share/cmake/Torch \
--cmake-args -DENABLE_CUDA=OFF -DUSE_ONNX=OFF && \
--cmake-args -DUSE_CUDA=OFF -DUSE_ONNX=OFF && \
catkin build
130 changes: 130 additions & 0 deletions docker/Dockerfile.x86_no_cuda
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# This is for x86 devices without cuda supported. For example RK3588
FROM ros:noetic-perception-focal
ARG CERES_VERSION=2.1.0
ARG OPENCV_VERSION=4.6.0
ENV SWARM_WS=/root/swarm_ws
ARG ROS_VERSION=noetic
ARG FAISS_VERSION=1.7.4
ARG CMAKE_VERSION=3.24.1
ARG ONNX_VERSION=1.13.1

#Some basic dependencies
RUN apt-get -y update && \
DEBIAN_FRONTEND=noninteractive TZ=Asia/Beijing apt-get -y install tzdata && \
apt-get install -y wget curl lsb-release git \
libatlas-base-dev \
libeigen3-dev \
libgoogle-glog-dev \
libsuitesparse-dev \
libglib2.0-dev \
libyaml-cpp-dev \
libdw-dev \
lsb-release \
vim \
curl \
ca-certificates \
htop \
xterm \
gdb \
build-essential \
net-tools \
htop \
xterm \
gdb \
zip \
unzip

#ROS
RUN apt-get install -y --no-install-recommends \
ros-${ROS_VERSION}-ros-base \
ros-${ROS_VERSION}-nav-msgs \
ros-${ROS_VERSION}-sensor-msgs \
ros-${ROS_VERSION}-cv-bridge \
ros-${ROS_VERSION}-rviz \
ros-${ROS_VERSION}-image-transport-plugins \
ros-${ROS_VERSION}-pcl-ros \
build-essential \
libdw-dev \
ros-${ROS_VERSION}-catkin \
python3-catkin-tools python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential \
python3-pip && \
apt clean

#Replace CMAKE
RUN rm /usr/bin/cmake && \
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh \
-q -O /tmp/cmake-install.sh \
&& chmod u+x /tmp/cmake-install.sh \
&& /tmp/cmake-install.sh --skip-license --prefix=/usr/ \
&& rm /tmp/cmake-install.sh \
&& cmake --version

#Install ceres
RUN git clone https://github.com/HKUST-Swarm/ceres-solver -b D2SLAM && \
cd ceres-solver && \
mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARKS=OFF .. && \
make -j$(nproc) install && \
rm -rf ../../ceres-solver

#Install ONNXRuntime with CUDA and TensorRT
RUN wget https://github.com/microsoft/onnxruntime/releases/download/v${ONNX_VERSION}/onnxruntime-linux-aarch64-${ONNX_VERSION}.tgz && \
tar -zxvf onnxruntime-linux-aarch64-${ONNX_VERSION}.tgz && \
cp -r onnxruntime-linux-aarch64-${ONNX_VERSION}/include/* /usr/local/include/ && \
cp -r onnxruntime-linux-aarch64-${ONNX_VERSION}/lib/* /usr/local/lib/ && \
rm -rf onnxruntime-linux-aarch64-${ONNX_VERSION} && \
rm onnxruntime-linux-aarch64-${ONNX_VERSION}.tgz

#Install LCM
RUN git clone https://github.com/lcm-proj/lcm && \
cd lcm && \
git checkout tags/v1.4.0 && \
mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARKS=OFF .. && \
make -j$(nproc) install && \
pip3 install lcm && \
rm -rf ../../lcm/

#Install Faiss
RUN git clone -b v${FAISS_VERSION} --single-branch https://github.com/facebookresearch/faiss.git && \
cd faiss && \
cmake -B build -DCMAKE_BUILD_TYPE=Release -DFAISS_OPT_LEVEL=NEON -DFAISS_ENABLE_PYTHON=OFF -DBUILD_TESTING=OFF -DFAISS_ENABLE_GPU=OFF . && \
make -C build -j$(nproc) faiss && \
make -C build install && \
rm -rf ../faiss

#Install OpenGV
RUN git clone https://github.com/HKUST-Swarm/opengv && \
mkdir opengv/build && cd opengv/build && cmake .. && make -j$(nproc) && \
make install && \
rm -rf ../../opengv

#Install Backward
RUN wget https://raw.githubusercontent.com/bombela/backward-cpp/master/backward.hpp -O /usr/local/include/backward.hpp

#Install spdlog
RUN wget https://github.com/gabime/spdlog/archive/refs/tags/v1.12.0.tar.gz && \
tar -zxvf v1.12.0.tar.gz && \
cd spdlog-1.12.0 && \
mkdir build && cd build && \
cmake .. && make -j$(nproc) && \
make install && \
rm -rf ../../spdlog-1.12.0

RUN wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcpu.zip && \
unzip libtorch-cxx11-abi-shared-with-deps-2.0.1+cpu.zip && \
rm libtorch-cxx11-abi-shared-with-deps-2.0.1+cpu.zip && \
cp -r libtorch/* /usr/local/

#Build D2SLAM
RUN mkdir -p ${SWARM_WS}/src/ && \
cd ${SWARM_WS}/src/ && \
git clone https://github.com/HKUST-Swarm/swarm_msgs.git -b D2SLAM && \
git clone https://github.com/HKUST-Swarm/sync_bag_player.git && \
git clone https://github.com/ros-perception/vision_opencv.git -b ${ROS_VERSION} --single-branch
COPY ./ ${SWARM_WS}/src/D2SLAM
WORKDIR $SWARM_WS
RUN . "/opt/ros/${ROS_VERSION}/setup.sh" && \
catkin config -DCMAKE_BUILD_TYPE=Release \
--cmake-args -DUSE_CUDA=OFF -DUSE_ONNX=OFF && \
catkin build
3 changes: 3 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ help:
x86:
@docker build -t hkustswarm/d2slam:x86 -f ./Dockerfile.x86 ..

x86_no_cuda:
@docker build -t hkustswarm/d2slam:x86_no_cuda -f ./Dockerfile.x86_no_cuda ..

jetson_orin:
@docker build -t hkustswarm/d2slam:jetson_orin -f ./Dockerfile.jetson ..

Expand Down
14 changes: 13 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Our Docker image includes:
- Backward
- $D^2$SLAM


## Docker PC

To build the Docker image for PC, run the following command:
Expand All @@ -21,7 +22,6 @@ To build the Docker image for PC, run the following command:
$ make pc
```


## Docker for Jetson

This Docker file can be built on a MacBook with Apple Silicon (M1 or M2), X86_64 PC with [qemu support](https://www.stereolabs.com/docs/docker/building-arm-container-on-x86/) or on Jetson. However, in our tests, building on Jetson is takes hours and building on Qemu is even more slow.
Expand All @@ -34,6 +34,18 @@ To build the Docker image for $D^2$ SLAM, run:
$ make jetson
```

# No-CUDA configuration

Target arm64 (Dockerfile.arm64_ros1_noetic) and x86_no_cuda (Dockerfile.x86_no_cuda) provide non-cuda configuration for arm64 and X86-64 devices. Others will depends on CUDA.
D2VINS only has fully abaility when using CUDA, features will be unsupported without CUDA:

- Superpoint and NetVLAD. You can only work with LK optical tracking.
- Loop clousure and pose graph
- Multi-robot localization will be disabled without CUDA
- Depth generation


Basically, without CUDA, D2SLAM will become a mono/stereo/quad camera visual-inertial odometry (VIO).

### Build Base Container (Optional)

Expand Down

0 comments on commit d08c6d3

Please sign in to comment.