Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[v1.7.x] update jetson dockerfile to support CUDA 10.0 #18339

Merged
merged 11 commits into from
May 26, 2020
96 changes: 43 additions & 53 deletions ci/docker/Dockerfile.build.jetson
Original file line number Diff line number Diff line change
Expand Up @@ -20,68 +20,58 @@
# This script assumes /work/mxnet exists and contains the mxnet code you wish to compile and
# that /work/build exists and is the target for your output.

FROM nvidia/cuda:9.0-cudnn7-devel as cudabuilder
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04

FROM dockcross/linux-arm64
ENV ARCH=aarch64 \
HOSTCC=gcc \
TARGET=ARMV8

ENV ARCH aarch64
ENV HOSTCC gcc
ENV TARGET ARMV8
WORKDIR /usr/local

# gh issue #11567 https://github.com/apache/incubator-mxnet/issues/11567
#RUN sed -i '\#deb http://cdn-fastly.deb.debian.org/debian-security jessie/updates main#d' /etc/apt/sources.list
#RUN sed -i 's/cdn-fastly.//' /etc/apt/sources.list
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
ninja-build \
git \
curl \
zip \
unzip \
python3 \
python3-pip \
awscli \
crossbuild-essential-arm64 \
&& rm -rf /var/lib/apt/lists/*

# cmake on Ubuntu 18.04 is too old
RUN python3 -m pip install cmake

WORKDIR /work/deps

COPY install/ubuntu_arm.sh /work/
RUN /work/ubuntu_arm.sh

COPY install/arm_openblas.sh /work/
RUN /work/arm_openblas.sh

ENV OpenBLAS_HOME=${CROSS_ROOT}
ENV OpenBLAS_DIR=${CROSS_ROOT}

# ccache on Ubuntu 18.04 is too old to support Cuda correctly
COPY install/deb_ubuntu_ccache.sh /work/
RUN /work/deb_ubuntu_ccache.sh

# Setup CUDA build env (including configuring and copying nvcc)
COPY --from=cudabuilder /usr/local/cuda /usr/local/cuda
ENV TARGET_ARCH aarch64
ENV TARGET_OS linux
COPY toolchains/aarch64-linux-gnu-toolchain.cmake /usr
ENV CMAKE_TOOLCHAIN_FILE=/usr/aarch64-linux-gnu-toolchain.cmake

RUN git clone --recursive -b v0.3.9 https://github.com/xianyi/OpenBLAS.git && \
cd /usr/local/OpenBLAS && \
make NOFORTRAN=1 CC=aarch64-linux-gnu-gcc && \
make PREFIX=/usr/aarch64-linux-gnu install && \
cd /usr/local && \
rm -rf OpenBLAS

# Install ARM depedencies based on Jetpack 3.3
RUN JETPACK_DOWNLOAD_PREFIX=https://developer.download.nvidia.com/devzone/devcenter/mobile/jetpack_l4t/3.3/lw.xd42/JetPackL4T_33_b39 && \
CUDA_REPO_PREFIX=/var/cuda-repo-9-0-local && \
ARM_CUDA_INSTALLER_PACKAGE=cuda-repo-l4t-9-0-local_9.0.252-1_arm64.deb && \
ARM_CUDNN_INSTALLER_PACKAGE=libcudnn7_7.1.5.14-1+cuda9.0_arm64.deb && \
ARM_CUDNN_DEV_INSTALLER_PACKAGE=libcudnn7-dev_7.1.5.14-1+cuda9.0_arm64.deb && \
ARM_LICENSE_INSTALLER=cuda-license-9-0_9.0.252-1_arm64.deb && \
ARM_CUBLAS_INSTALLER=cuda-cublas-9-0_9.0.252-1_arm64.deb && \
ARM_NVINFER_INSTALLER_PACKAGE=libnvinfer4_4.1.3-1+cuda9.0_arm64.deb && \
ARM_NVINFER_DEV_INSTALLER_PACKAGE=libnvinfer-dev_4.1.3-1+cuda9.0_arm64.deb && \
dpkg --add-architecture arm64 && \
wget -nv $JETPACK_DOWNLOAD_PREFIX/$ARM_CUDA_INSTALLER_PACKAGE && \
wget -nv $JETPACK_DOWNLOAD_PREFIX/$ARM_CUDNN_INSTALLER_PACKAGE && \
wget -nv $JETPACK_DOWNLOAD_PREFIX/$ARM_CUDNN_DEV_INSTALLER_PACKAGE && \
wget -nv $JETPACK_DOWNLOAD_PREFIX/$ARM_NVINFER_INSTALLER_PACKAGE && \
wget -nv $JETPACK_DOWNLOAD_PREFIX/$ARM_NVINFER_DEV_INSTALLER_PACKAGE && \
dpkg -i --force-architecture $ARM_CUDA_INSTALLER_PACKAGE && \
apt-key add $CUDA_REPO_PREFIX/7fa2af80.pub && \
dpkg -i --force-architecture $ARM_CUDNN_INSTALLER_PACKAGE && \
dpkg -i --force-architecture $ARM_CUDNN_DEV_INSTALLER_PACKAGE && \
dpkg -i --force-architecture $CUDA_REPO_PREFIX/$ARM_LICENSE_INSTALLER && \
dpkg -i --force-architecture $CUDA_REPO_PREFIX/$ARM_CUBLAS_INSTALLER && \
dpkg -i --force-architecture $ARM_NVINFER_INSTALLER_PACKAGE && \
dpkg -i --force-architecture $ARM_NVINFER_DEV_INSTALLER_PACKAGE && \
apt update -y || true && apt install -y cuda-libraries-dev-9-0 libcudnn7-dev libnvinfer-dev
RUN ln -s /usr/include/aarch64-linux-gnu/cudnn_v7.h /usr/include/aarch64-linux-gnu/cudnn.h
ENV PATH $PATH:/usr/local/cuda/bin
ENV NVCCFLAGS "-m64"
ENV CUDA_ARCH "-gencode arch=compute_53,code=sm_53 -gencode arch=compute_62,code=sm_62"
ENV NVCC /usr/local/cuda/bin/nvcc
# Install aarch64 cross depedencies based on Jetpack 4.3
# Manually downloaded using SDK Manager tool and placed in a private S3 bucket.
# We're not allowed to redistribute these files and there is no public version.
RUN aws s3 cp s3://mxnet-ci-prod-private-slave-data/nvidia/sdkm_downloads/cuda-repo-ubuntu1804-10-0-local-10.0.326-410.108_1.0-1_amd64.deb . && \
dpkg -i cuda-repo-ubuntu1804-10-0-local-10.0.326-410.108_1.0-1_amd64.deb && \
rm cuda-repo-ubuntu1804-10-0-local-10.0.326-410.108_1.0-1_amd64.deb && \
apt-key add /var/cuda-repo-10-0-local-10.0.326-410.108/7fa2af80.pub && \
aws s3 cp s3://mxnet-ci-prod-private-slave-data/nvidia/sdkm_downloads/cuda-repo-cross-aarch64-10-0-local-10.0.326_1.0-1_all.deb . && \
dpkg -i cuda-repo-cross-aarch64-10-0-local-10.0.326_1.0-1_all.deb && \
rm cuda-repo-cross-aarch64-10-0-local-10.0.326_1.0-1_all.deb && \
apt-get update && \
apt-get install -y -f && \
apt-get install -y cuda-cross-aarch64 cuda-cross-aarch64-10-0 && \
rm -rf /var/lib/apt/lists/*

ARG USER_ID=0
ARG GROUP_ID=0
Expand Down
25 changes: 16 additions & 9 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,22 @@ build_dynamic_libmxnet() {

build_jetson() {
set -ex
pushd .

#build_ccache_wrappers

cp make/crosscompile.jetson.mk ./config.mk
make -j$(nproc)

build_wheel /work/mxnet/python /work/mxnet/lib
popd
cd /work/build
cmake \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \
-DUSE_CUDA=ON \
-DMXNET_CUDA_ARCH="5.2" \
-DENABLE_CUDA_RTC=OFF \
-DSUPPORT_F16C=OFF \
-DUSE_OPENCV=OFF \
-DUSE_OPENMP=ON \
-DUSE_LAPACK=OFF \
-DUSE_SIGNAL_HANDLER=ON \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_MKL_IF_AVAILABLE=OFF \
-G Ninja /work/mxnet
ninja
build_wheel
}

#
Expand Down
28 changes: 28 additions & 0 deletions ci/docker/toolchains/aarch64-linux-gnu-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR "aarch64")
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_CUDA_HOST_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_FIND_ROOT_PATH "/usr/aarch64-linux-gnu")

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
27 changes: 27 additions & 0 deletions ci/docker/toolchains/arm-linux-gnueabihf-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR "armv7l")
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
set(CMAKE_FIND_ROOT_PATH "/usr/arm-linux-gnueabihf" "/usr/local/arm-linux-gnueabihf")

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
Loading