[go: nahoru, domu]

Skip to content

Commit

Permalink
build updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dusty-nv committed Mar 3, 2022
1 parent 3a032b0 commit deea461
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 20 deletions.
30 changes: 18 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ file(COPY "tools/install-pytorch.sh" DESTINATION ${PROJECT_BINARY_DIR})
file(COPY "tools/install-pytorch.rc" DESTINATION ${PROJECT_BINARY_DIR})


# detect distro version
find_program(LSB_RELEASE_EXEC lsb_release)

execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --id OUTPUT_VARIABLE LSB_RELEASE_ID OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --release OUTPUT_VARIABLE LSB_RELEASE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --codename OUTPUT_VARIABLE LSB_RELEASE_CODENAME OUTPUT_STRIP_TRAILING_WHITESPACE)

message("-- distro ID: ${LSB_RELEASE_ID}")
message("-- distro version: ${LSB_RELEASE_VERSION}")
message("-- distro codename: ${LSB_RELEASE_CODENAME}")


# if this is the first time running cmake, perform pre-build dependency install script (or if the user manually triggers re-building the dependencies)
if( ${BUILD_DEPS} )
message("-- Launching pre-build dependency installer script...")
Expand All @@ -55,22 +67,16 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/utils/cu
find_package(CUDA)
message("-- CUDA version: ${CUDA_VERSION}")

set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};
-O3
-gencode arch=compute_53,code=sm_53
-gencode arch=compute_62,code=sm_62
)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -O3 -gencode arch=compute_53,code=sm_53 -gencode arch=compute_62,code=sm_62)

if(CUDA_VERSION_MAJOR GREATER 9)
message("-- CUDA ${CUDA_VERSION_MAJOR} detected, enabling SM_72")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -gencode arch=compute_72,code=sm_72)
endif()

set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};
-gencode arch=compute_72,code=sm_72
)
if(CUDA_VERSION_MAJOR GREATER 10)
message("-- CUDA ${CUDA_VERSION_MAJOR} detected, enabling SM_87")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -gencode arch=compute_87,code=sm_87)
endif()

# setup project output paths
Expand Down
9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ FROM ${BASE_IMAGE}

ENV DEBIAN_FRONTEND=noninteractive
ENV SHELL /bin/bash
ARG PYTHON3_VERSION=3.8

WORKDIR jetson-inference

Expand All @@ -43,17 +44,13 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends \
cmake \
nano \
lsb-release \
&& rm -rf /var/lib/apt/lists/*

# pip dependencies for pytorch-ssd
RUN pip3 install --verbose --upgrade Cython && \
pip3 install --verbose boto3 pandas

# alias python3 -> python
RUN rm /usr/bin/python && \
ln -s /usr/bin/python3 /usr/bin/python && \
ln -s /usr/bin/pip3 /usr/bin/pip


#
# install OpenCV (with CUDA)
Expand All @@ -75,7 +72,7 @@ RUN apt-get purge -y '*opencv*' || echo "previous OpenCV installation not found"
cd ../ && \
rm -rf opencv && \
cp -r /usr/include/opencv4 /usr/local/include/opencv4 && \
cp -r /usr/lib/python3.6/dist-packages/cv2 /usr/local/lib/python3.6/dist-packages/cv2
cp -r /usr/lib/python${PYTHON3_VERSION}/dist-packages/cv2 /usr/local/lib/python${PYTHON3_VERSION}/dist-packages/cv2


#
Expand Down
18 changes: 18 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,27 @@ if [ -f "$CV_CSV" ]; then
fi


# distro release-dependent build options
LSB_RELEASE=$(lsb_release --codename --short)

OPENCV_URL="https://nvidia.box.com/shared/static/5v89u6g5rb62fpz4lh0rz531ajo2t5ef.gz"
OPENCV_DEB="OpenCV-4.5.0-aarch64.tar.gz"

PYTHON3_VERSION="3.6"

if [ $LSB_RELEASE = "focal" ]; then
echo "configuring docker build for $LSB_RELEASE"
OPENCV_URL="https://nvidia.box.com/shared/static/2hssa5g3v28ozvo3tc3qwxmn78yerca9.gz"
PYTHON3_VERSION="3.8"
fi


# build the container
sudo docker build -t jetson-inference:r$L4T_VERSION -f Dockerfile \
--build-arg BASE_IMAGE=$BASE_IMAGE \
--build-arg PYTHON3_VERSION=$PYTHON3_VERSION \
--build-arg OPENCV_URL=$OPENCV_URL \
--build-arg OPENCV_DEB=$OPENCV_DEB \
.


Expand Down
2 changes: 2 additions & 0 deletions docker/tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ if [ $L4T_RELEASE -eq 32 ]; then
else
version_error
fi
elif [ $L4T_RELEASE -eq 34 ]; then
CONTAINER_REMOTE_IMAGE="dustynv/$CONTAINER_IMAGE"
else
version_error
fi
Expand Down
6 changes: 5 additions & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#
# If you want to support another version of Python, add it here.
#
set(PYTHON_BINDING_VERSIONS 2.7 3.6 3.7)
if(LSB_RELEASE_CODENAME MATCHES "focal")
set(PYTHON_BINDING_VERSIONS 3.8)
else()
set(PYTHON_BINDING_VERSIONS 2.7 3.6 3.7)
endif()

message("-- trying to build Python bindings for Python versions: ${PYTHON_BINDING_VERSIONS}")

Expand Down
2 changes: 1 addition & 1 deletion utils

0 comments on commit deea461

Please sign in to comment.