From 43cbc72f33eb705e5edf2e98f7a7b78bed15a9c8 Mon Sep 17 00:00:00 2001 From: Yoshiki Obinata Date: Thu, 6 Feb 2025 01:32:57 +0900 Subject: [PATCH] Make l4t container buildable --- .dockerignore | 2 - .gitignore | 2 + l4t.Dockerfile | 126 ++++++++++--------------------------------------- 3 files changed, 28 insertions(+), 102 deletions(-) delete mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index df92510..0000000 --- a/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -Dockerfile -l4t.Dockerfile \ No newline at end of file diff --git a/.gitignore b/.gitignore index c067b61..e22337a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +requirements.txt + /models /test/data diff --git a/l4t.Dockerfile b/l4t.Dockerfile index 1f78be2..eecca97 100644 --- a/l4t.Dockerfile +++ b/l4t.Dockerfile @@ -1,113 +1,39 @@ FROM nvcr.io/nvidia/l4t-pytorch:r35.1.0-pth1.11-py3 -ENV DEBIAN_FRONTEND=noninteractive - -RUN echo 'Etc/UTC' > /etc/timezone && \ - apt-get update && \ - apt-get install -q -y --no-install-recommends tzdata && \ - rm -rf /var/lib/apt/lists/* - -RUN \ - useradd user && \ - echo "user ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/user && \ - chmod 0440 /etc/sudoers.d/user && \ - mkdir -p /home/user && \ - chown user:user /home/user && \ - chsh -s /bin/bash user - -RUN echo 'root:root' | chpasswd -RUN echo 'user:user' | chpasswd -# install packages -RUN apt-get update && apt-get install -q -y --no-install-recommends \ - build-essential \ - sudo \ - git \ - dirmngr \ - gnupg2 \ - curl \ - lsb-release \ - wget \ - && rm -rf /var/lib/apt/lists/* - -# setup sources.list -RUN sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' - -# setup keys -RUN curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - - -# setup environment -ENV LANG C.UTF-8 -ENV LC_ALL C.UTF-8 -ENV ROS_DISTRO noetic +ENV DEBIAN_FRONTEND=noninteractive # Remove OpenCV built with CUDA by NVIDIA. It conflicts with original OpenCV deb RUN apt purge opencv-* -y -# install ros packages -RUN apt-get update && apt-get install -y --no-install-recommends \ - ros-noetic-ros-core=1.5.0-1* \ - ros-noetic-ros-base=1.5.0-1* \ - build-essential \ - python3-rosdep \ - python3-rosinstall \ - python3-vcstools \ - ros-noetic-jsk-tools \ - ros-noetic-image-transport-plugins \ - python3-osrf-pycommon \ - python3-catkin-tools \ - python3-wstool \ - ros-noetic-jsk-pcl-ros \ - ros-noetic-jsk-pcl-ros-utils \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /home/user - -USER user -CMD /bin/bash -SHELL ["/bin/bash", "-c"] +# Install ROS +RUN apt update && apt install -y -qq curl &&\ + sh -c 'echo "deb http://packages.ros.org/ros/ubuntu focal main" > /etc/apt/sources.list.d/ros-latest.list' &&\ + curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add - &&\ + apt update && apt install -y -qq \ + python3-catkin-tools python3-rosdep ros-noetic-desktop-full ros-noetic-jsk-recognition &&\ + rm -rf /var/lib/apt/lists/* -######################################## -########### WORKSPACE BUILD ############ -######################################## -# Installing catkin package -RUN mkdir -p ~/detic_ws/src -RUN sudo rosdep init && rosdep update +# Upgrade pip-setup related packages to make grpcio install faster. Without this line, the grpcio would be compiled from source and it takes so much time. +RUN pip3 install --upgrade pip 'setuptools<=68.2.2' wheel && rm -rf ~/.cache/pip # Build detectron2 from source. The aarch64 version is not released RUN cd /tmp &&\ - git clone -b v0.6 https://github.com/facebookresearch/detectron2 &&\ - pip3 install --no-cache-dir -e detectron2 - -RUN mkdir -p ~/detic_ws/src/detic_ros/node_script -COPY --chown=user requirements.txt /home/user/detic_ws/src/detic_ros -COPY --chown=user prepare.sh /home/user/detic_ws/src/detic_ros -RUN cd ~/detic_ws/src/detic_ros && ./prepare.sh &&\ + git clone --depth 1 -b v0.6 https://github.com/facebookresearch/detectron2 &&\ + pip3 install --no-cache-dir -e detectron2 &&\ rm -rf ~/.cache/pip -COPY --chown=user . /home/user/detic_ws/src/detic_ros -RUN cd ~/detic_ws/src/detic_ros && git submodule update --init --recursive -RUN cd ~/detic_ws/src &&\ - source /opt/ros/noetic/setup.bash &&\ - wstool init &&\ - wstool merge detic_ros/rosinstall.noetic &&\ - wstool update &&\ - sudo apt update &&\ - rosdep install --from-paths . --ignore-src -y -r &&\ - source /opt/ros/noetic/setup.bash &&\ - rosdep install --from-paths . -i -r -y &&\ - sudo rm -rf /var/lib/apt/lists/* &&\ - cd ~/detic_ws && catkin init && catkin build - -# to avoid conflcit when mounting -RUN rm -rf ~/detic_ws/src/detic_ros/launch - -######################################## -########### ENV VARIABLE STUFF ######### -######################################## -RUN touch ~/.bashrc -RUN echo "source ~/detic_ws/devel/setup.bash" >> ~/.bashrc -RUN echo 'export PATH="$PATH:$HOME/.local/bin"' >> ~/.bashrc - -RUN sudo usermod -aG video user +# Copy repository and install system dependencies +RUN rosdep init +RUN mkdir -p /catkin_ws/src/detic_ros +COPY package.xml /catkin_ws/src/detic_ros +RUN cd /catkin_ws/src/detic_ros &&\ + apt update &&\ + rosdep update &&\ + rosdep install --rosdistro=noetic -iqry --from-paths /catkin_ws/src &&\ + rm -rf /var/lib/apt/lists/* -CMD ["bash"] +# Build +COPY . /catkin_ws/src/detic_ros +RUN sed -i '1,3d' /catkin_ws/src/detic_ros/requirements_without_torch.txt +RUN cd /catkin_ws &&\ + /opt/ros/noetic/env.sh catkin build detic_ros --cmake-args -DDETIC_ROS_INSTALL_TORCH=OFF