From 8f20d23e03b9ba9baa297fa52d17b0f90b62b6be Mon Sep 17 00:00:00 2001 From: Anthony Tarbinian Date: Tue, 12 Mar 2024 19:44:42 -0700 Subject: [PATCH] github actions might work? --- .github/workflows/docker-jetson.yml | 2 +- .../workflows/{docker.yml => docker-x86.yml} | 10 ++- .../{Dockerfile.nvidia => Dockerfile.jetson} | 79 ++----------------- 3 files changed, 13 insertions(+), 78 deletions(-) rename .github/workflows/{docker.yml => docker-x86.yml} (88%) rename docker/{Dockerfile.nvidia => Dockerfile.jetson} (52%) diff --git a/.github/workflows/docker-jetson.yml b/.github/workflows/docker-jetson.yml index 9c9f43e1..d281ce4c 100644 --- a/.github/workflows/docker-jetson.yml +++ b/.github/workflows/docker-jetson.yml @@ -24,7 +24,7 @@ jobs: with: filters: | dockerfile: - - ${DOCKERFILE_JETSON} + - ${DOCKERFILE_PATH} build-and-push-image: needs: changes diff --git a/.github/workflows/docker.yml b/.github/workflows/docker-x86.yml similarity index 88% rename from .github/workflows/docker.yml rename to .github/workflows/docker-x86.yml index f9e7459b..9689fcad 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker-x86.yml @@ -1,4 +1,4 @@ -name: Push Docker Image +name: Push x86 Docker Image on: push: @@ -8,6 +8,8 @@ on: env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} + TAG: "x86" + DOCKERFILE_PATH: 'docker/Dockerfile.x86' jobs: changes: @@ -21,7 +23,7 @@ jobs: with: filters: | dockerfile: - - '.devcontainer/Dockerfile' + - ${DOCKERFILE_PATH} build-and-push-image: needs: changes @@ -50,9 +52,9 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: - file: .devcontainer/Dockerfile + file: ${DOCKERFILE_PATH} context: . push: true - tags: ${{ steps.meta.outputs.tags }} + tags: ${TAG} labels: ${{ steps.meta.outputs.labels }} diff --git a/docker/Dockerfile.nvidia b/docker/Dockerfile.jetson similarity index 52% rename from docker/Dockerfile.nvidia rename to docker/Dockerfile.jetson index 24159065..bba0392b 100644 --- a/docker/Dockerfile.nvidia +++ b/docker/Dockerfile.jetson @@ -1,8 +1,7 @@ -#FROM arm64v8/ubuntu:22.04 -#FROM dustynv/l4t-pytorch:r35.3.1 FROM tritonuas/jetson-base:r35.3.1 + # this base image came from dusty-nv/jetson-containers -# ./build.sh --name=tritonuas/jetson-base pytorch torchvision opencv +# ./build.sh --name=tritonuas/jetson-base pytorch:2.1 torchvision opencv ARG USERNAME=tuas USER_UID=1000 USER_GID=1000 DEBIAN_FRONTEND=noninteractive @@ -32,7 +31,6 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \ curl \ unzip \ protobuf-compiler \ - # libopencv-dev \ # Need these to install Python 3.11 from pyenv python3-pip \ libssl-dev \ @@ -43,46 +41,21 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \ libncursesw5-dev \ xz-utils \ tk-dev \ - # libxm12-dev \ libxmlsec1-dev \ libffi-dev \ liblzma-dev \ # needed for matplotplus gnuplot \ # imagemagick with c++ dependency - #graphicsmagick-libmagick-dev-compat libgraphicsmagick++1-dev libmagick++-6-headers \ libmagick++-dev \ - # needed for pytorch - libopenblas-dev - -#RUN apt-add-repository universe -#RUN apt-get install -y cpplint + # needed for pytorch + libopenblas-dev -# Update Python to 3.11 so that libtorch can be properly built from source -#ENV PYENV_ROOT="/.pyenv" -#RUN curl https://pyenv.run | bash -#ENV PATH="${PATH}:${PYENV_ROOT}/bin" -#RUN eval "$(pyenv init -)" -#RUN pyenv install 3.8 -#RUN pyenv global 3.8 RUN pip3 install typing-extensions PyYAML cpplint RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ && chmod 0440 /etc/sudoers.d/$USERNAME -# Download latest CMake from their repositories -#RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \ -# --mount=target=/var/cache/apt,type=cache,sharing=locked \ -# rm -f /etc/apt/apt.conf.d/docker-clean \ -# && apt-get update \ -# && wget https://github.com/Kitware/CMake/releases/download/v3.27.7/cmake-3.27.7-linux-aarch64.sh \ -# -q -O /tmp/cmake-install.sh \ -# && chmod u+x /tmp/cmake-install.sh \ -# && mkdir /opt/cmake-3.24.1 \ -# && /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-3.24.1 \ -# && rm /tmp/cmake-install.sh \ -# && ln -s /opt/cmake-3.24.1/bin/* /usr/local/bin - # install prebuilt MAVSDK to system # https://github.com/mavlink/MAVSDK/releases ARG MAVSDK_VERSION=1.4.17 @@ -91,58 +64,18 @@ RUN wget https://github.com/mavlink/MAVSDK/releases/download/v${MAVSDK_VERSION}/ && dpkg -i ${MAVSDK_DEB} \ && rm ${MAVSDK_DEB} -# the official docs say also these -# https://docs.opencv.org/4.x/d7/d9f/tutorial_linux_install.html -# cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -# python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev - -# pull pre-built libtorch -#ARG LIBTORCH_VERSION=2.1.0 -#ARG LIBTORCH_INSTALL_DIR=/libtorch-tmp -#WORKDIR ${LIBTORCH_INSTALL_DIR} -#RUN git clone -b main --recurse-submodule https://github.com/pytorch/pytorch.git -#RUN mkdir pytorch-build -#RUN cd pytorch-build -#RUN cmake -DWITH_CUDA=ON -D_GLIBCXX_USE_CXX11_ABI=1 -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=Release -DPYTHON_EXECUTABLE:PATH=`which python3` -DCMAKE_PREFIX_PATH=../pytorch-install ${LIBTORCH_INSTALL_DIR}/pytorch -#RUN cmake --build . --target install - -# https://forums.developer.nvidia.com/t/pytorch-for-jetson/72048 - -# Make sure this is compatible with our version of torchvision -ARG LIBTORCH_VERSION=torch-1.13.0a0+d0d6b1f2.nv22.10-cp38-cp38-linux_aarch64.whl -#torch-2.1.0a0+41361538.nv23.06-cp38-cp38-linux_aarch64.whl -# Version of Jetson Software. Includes major and minor version numbers. Version 5.0 is 50 and 4.6.1 is 461. -ARG JETPACK_VERSION=512 -#RUN pip3 install numpy==1.26.1 && pip3 install --no-cache https://developer.download.nvidia.cn/compute/redist/jp/v512/pytorch/torch-2.1.0a0+41361538.nv23.06-cp38-cp38-linux_aarch64.whl -#https://developer.download.nvidia.com/compute/redist/jp/v${JETPACK_VERSION}/pytorch/${LIBTORCH_VERSION} - -# RUN wget "https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-${LIBTORCH_VERSION}%2Bcpu.zip" \ -# && unzip "libtorch-cxx11-abi-shared-with-deps-${LIBTORCH_VERSION}+cpu.zip" -# needed to build torchvision below and to build targets that use libtorch inside the container -#ENV CMAKE_PREFIX_PATH="${LIBTORCH_INSTALL_DIR}/libtorch" - # pull and build torchvision # refer to this page for version compatibilty with pytorch (libtorch) https://github.com/pytorch/pytorch/wiki/PyTorch-Versions ARG TORCHVISION_VERSION=0.16.0 -#ARG TORCHVISION_INSTALL_DIR=/torchvision-tmp -WORKDIR ${TORCHVISION_INSTALL_DIR} RUN wget "https://github.com/pytorch/vision/archive/refs/tags/v${TORCHVISION_VERSION}.zip" \ && unzip "v${TORCHVISION_VERSION}.zip" \ - && cd vision-0.16.0 \ + && cd "vision-${TORCHVISION_VERSION}" \ && mkdir build \ && cd build \ && cmake -DWITH_CUDA=1 -DCUDA_HAS_FP16=1 -DCUDA_NO_HALF_OPERATORS=1 -DCUDA_NO_HALF_CONVERSIONS=1 -DCUDA_NO_HALF2_OPERATORS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/usr/local/lib/python3.8/dist-packages/torch/share/cmake/Torch" .. \ && make -j2 \ && make install - #&& WITH_CUDA=1 python3 setup.py install - - #&& mkdir -p "${TORCHVISION_INSTALL_DIR}/vision-${TORCHVISION_VERSION}/build" \ - #&& cd "${TORCHVISION_INSTALL_DIR}/vision-${TORCHVISION_VERSION}/build" \ - #&& cmake -DWITH_CUDA=1 -DCUDA_HAS_FP16=1 -D__CUDA_NO_HALF_OPERATORS__=1 -D__CUDA_NO_HALF_CONVERSIONS__=1 -D__CUDA_NO_HALF2_OPERATORS__=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/usr/local/lib/python3.8/dist-packages/torch/share/cmake/Torch" .. \ - #&& make -j2 \ - #&& make install - # Install g++10 and replace the older version. For some reason some c++ 20 features aren't working with g++9 even though # we have CMake configured to use c++ 20 https://stackoverflow.com/questions/69037873/why-am-i-missing-c20-headers-and-how-do-i-fix-this RUN apt-get update && apt-get install -y g++-10 gcc-10 @@ -157,7 +90,7 @@ COPY . . RUN rm -rf /obcpp/build WORKDIR /obcpp/build ENV CMAKE_PREFIX_PATH="/usr/local/lib/python3.8/dist-packages/torch/share/cmake/Torch;/usr/local/share/cmake/TorchVision" -RUN GITHUB_ACTIONS=true cmake -DCMAKE_PREFIX_PATH="/usr/local/lib/python3.8/dist-packages/torch/share/cmake/Torch;/usr/local/share/cmake/TorchVision" -DCMAKE_MODULE_PATH="/usr/local/share/cmake/TorchVision" -DCMAKE_BUILD_TYPE="Debug" .. +RUN GITHUB_ACTIONS=true cmake -DCMAKE_PREFIX_PATH="/usr/local/lib/python3.8/dist-packages/torch/share/cmake/Torch;/usr/local/share/cmake/TorchVision" -DCMAKE_MODULE_PATH="/usr/local/share/cmake/TorchVision" -DCMAKE_BUILD_TYPE="Release" .. RUN make load_torchvision_model VERBOSE=1