提交 0878b9ed 编写于 作者: S storypku 提交者: Liu Jiaming

Docker::Installers: 1) added magma binary & source installer to be used by libtorch

2) Bugfix for upstream mkl==2021.1.1 installer

Please note that binary Magma release should be aligned with SUPPORTED_NVIDIA_SMS
from installer_base.sh, once SUPPORTED_NVIDIA_SMS changed, please
rebuild Magma also.

3) Docker::Installers: libtorch-1.6.0-1 for x86_64.stable with magma support
上级 12ffa343
......@@ -27,10 +27,9 @@ apt_get_update_and_install \
libatlas-base-dev \
liblapack-dev
TARGET_ARCH="$(uname -m)"
# Note(storypku):
# 1) cublas was already installed before this installer runs
# Note(infra): build magma before mkl
info "Install Magma ..."
bash ${CURR_DIR}/install_magma.sh
info "Install libtorch ..."
bash ${CURR_DIR}/install_libtorch.sh
......
......@@ -18,8 +18,8 @@
set -e
cd "$(dirname "${BASH_SOURCE[0]}")"
. ./installer_base.sh
CURR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
. ${CURR_DIR}/installer_base.sh
# TODO(build): Docs on how to build libtorch on Jetson boards
# References:
......@@ -27,45 +27,18 @@ cd "$(dirname "${BASH_SOURCE[0]}")"
# https://github.com/dusty-nv/jetson-containers/blob/master/Dockerfile.pytorch
# https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-6-0-now-available
# https://github.com/pytorch/pytorch/blob/master/docker/caffe2/ubuntu-16.04-cpu-all-options/Dockerfile
bash ${CURR_DIR}/install_mkl.sh
TARGET_ARCH="$(uname -m)"
if [[ "${TARGET_ARCH}" == "x86_64" ]]; then
# Libtorch-gpu dependency for x86_64
pip3_install mkl==2021.1.1
# Workaround for duplicate entries in mkl installation
MKL_LIBDIR="/usr/local/lib"
for so in ${MKL_LIBDIR}/libmkl*.so; do
so1="${so}.1"
if [[ "$(basename ${so})" == "libmkl_sycl.so" ]]; then
if [[ -f "${so1}" ]]; then
rm -f ${so1}
fi
rm -f ${so}
continue
fi
if [[ -f "${so}.1" ]]; then
cs1=$(sha256sum ${so1} | awk '{print $1}')
cs0=$(sha256sum ${so} | awk '{print $1}')
if [[ "${cs1}" == "${cs0}" ]]; then
so1_name="$(basename $so1)"
warning "Duplicate so ${so} with ${so1_name} found, re-symlinking..."
info "Now perform: rm -f ${so} && ln -s ${so1_name} ${so}"
rm -f ${so} && ln -s ${so1_name} ${so}
fi
fi
done
fi
##============================================================##
# libtorch_cpu
if [[ "${TARGET_ARCH}" == "x86_64" ]]; then
if [[ "${APOLLO_DIST}" == "stable" ]]; then
# https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.5.0%2Bcpu.zip
VERSION="1.6.0"
CHECKSUM="2bc75f4b38e7c23f99a2e0367b64c8626cac1442e87b7ab9878859bbf10973fe"
VERSION="1.6.0-1"
CHECKSUM="4931fe651f2098ee3f0c4147099bd5dddcc15c0e9108e49a5ffdf46d98a7092a"
else # testing
VERSION="1.7.0"
CHECKSUM="1baccc141347ce33cd998513f5cfdb0b5c359d66cd2b59b055c9eadc9e954d19"
......@@ -92,9 +65,9 @@ ok "Successfully installed libtorch_cpu ${VERSION}"
# libtorch_gpu
if [[ "${TARGET_ARCH}" == "x86_64" ]]; then
if [[ "${APOLLO_DIST}" == "stable" ]]; then
VERSION="1.6.0"
CHECKSUM="ab540c8d6c088ca5eda0e861bb39e985b046f363c3a1fbd65176090c202f8af3"
PKG_NAME="libtorch_gpu-1.6.0-cu102-linux-x86_64.tar.gz"
VERSION="1.6.0-1"
CHECKSUM="8ca52235cb91aba6d39fb144ec5414bebf0e94a2ee03115ae83650fc4d421719"
PKG_NAME="libtorch_gpu-${VERSION}-cu102-linux-x86_64.tar.gz"
else
VERSION="1.7.0"
CHECKSUM="d2356b641d78e33d5decebf8c32f726b831045d5a0aff276545b40a259225885"
......
#! /usr/bin/env bash
###############################################################################
# Copyright 2021 The Apollo Authors. All Rights Reserved.
#
# Licensed 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 -e
CURR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
. ${CURR_DIR}/installer_base.sh
if ldconfig -p | grep -q magma ; then
warning "Magma already installed, re-installation skipped."
exit 0
fi
: ${INSTALL_MODE:=download}
: ${APOLLO_DIST:=stable}
GPU_ARCHS=
function determine_gpu_targets() {
IFS=' ' read -r -a sms <<< "${SUPPORTED_NVIDIA_SMS}"
local archs=
for sm in "${sms[@]}"; do
if [[ -z "${archs}" ]]; then
archs="sm_${sm//./}"
else
archs+=" sm_${sm//./}"
fi
done
GPU_ARCHS="${archs}"
}
determine_gpu_targets
apt_get_update_and_install \
libopenblas-dev \
gfortran
TARGET_ARCH="$(uname -m)"
VERSION="2.5.4"
if [[ "${INSTALL_MODE}" == "download" ]]; then
if [[ "${TARGET_ARCH}" == "x86_64" ]]; then
if [[ "${APOLLO_DIST}" == "stable" ]]; then
CHECKSUM="962447d0f4dfbfade34d4b1dd8658a97b6fdeb88340637581566f24861a60812"
PKG_NAME="magma-${VERSION}-cu102-x86_64.tar.gz"
else
CHECKSUM="TODO"
PKG_NAME="magma-${VERSION}-cu111-x86_64.tar.gz"
fi
else # AArch64
CHECKSUM="TODO"
PKG_NAME="magma-${VERSION}-aarch64.tar.gz"
fi
DOWNLOAD_LINK="https://apollo-system.cdn.bcebos.com/archive/6.0/${PKG_NAME}"
download_if_not_cached "${PKG_NAME}" "${CHECKSUM}" "${DOWNLOAD_LINK}"
tar xzf ${PKG_NAME}
pushd ${PKG_NAME%.tar.gz}
mv include/* ${SYSROOT_DIR}/include/
mv lib/*.so ${SYSROOT_DIR}/lib/
[[ -d ${SYSROOT_DIR}/lib/pkgconfig ]] || mkdir -p ${SYSROOT_DIR}/lib/pkgconfig
install -t ${SYSROOT_DIR}/lib/pkgconfig lib/pkgconfig/magma.pc
popd
rm -rf ${PKG_NAME%.tar.gz} ${PKG_NAME}
ok "Successfully installed magma-${VERSION} in download mode"
else
PKG_NAME="magma-${VERSION}.tar.gz"
DOWNLOAD_LINK="http://icl.utk.edu/projectsfiles/magma/downloads/${PKG_NAME}"
CHECKSUM="7734fb417ae0c367b418dea15096aef2e278a423e527c615aab47f0683683b67"
download_if_not_cached "${PKG_NAME}" "${CHECKSUM}" "${DOWNLOAD_LINK}"
tar xzf ${PKG_NAME}
pushd magma-${VERSION}
mkdir build && cd build
cmake .. \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX="${SYSROOT_DIR}" \
-DCMAKE_BUILD_TYPE=Release \
-DGPU_TARGET="${GPU_ARCHS}"
# E.g., sm_52 sm_60 sm_61 sm_70 sm_75
make -j$(nproc)
make install
popd
rm -rf magma-${VERSION} ${PKG_NAME}
fi
ldconfig
if [[ -n "${CLEAN_DEPS}" ]]; then
apt_get_remove gfortran
fi
#!/usr/bin/env bash
###############################################################################
# Copyright 2021 The Apollo Authors. All Rights Reserved.
#
# Licensed 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 -e
cd "$(dirname "${BASH_SOURCE[0]}")"
. ./installer_base.sh
TARGET_ARCH="$(uname -m)"
if [[ "${TARGET_ARCH}" != "x86_64" ]]; then
exit 0
fi
pip3_install mkl==2021.1.1
# Workaround for removing duplicate entries in mkl PYPI installation
function mkl_relink {
MKL_LIBDIR="/usr/local/lib"
for so in ${MKL_LIBDIR}/libmkl*.so; do
so1="${so}.1"
if [[ "$(basename ${so})" == "libmkl_sycl.so" ]]; then
rm -f ${so} ${so1} || true
continue
fi
if [[ -f "${so}.1" ]]; then
cs1=$(sha256sum ${so1} | awk '{print $1}')
cs0=$(sha256sum ${so} | awk '{print $1}')
if [[ "${cs1}" == "${cs0}" ]]; then
so1_name="$(basename $so1)"
warning "Duplicate so ${so} with ${so1_name} found, re-symlinking..."
info "Now perform: rm -f ${so} && ln -s ${so1_name} ${so}"
rm -f ${so} && ln -s ${so1_name} ${so}
fi
fi
done
}
function tbb_relink() {
TBB_LIBDIR="/usr/local/lib"
for so in ${TBB_LIBDIR}/libtbb*.so*; do
soname="$(basename ${so})"
IFS='.' read -ra arr <<< "${soname}"
IFS=' ' # restore IFS
num=${#arr[@]}
if [[ ${num} != 4 ]]; then # Keep only libtbb.so.12.1
rm -f ${so} || true
fi
done
for so in ${TBB_LIBDIR}/libtbb*.so*; do
soname="$(basename ${so})"
IFS='.' read -ra arr <<< "${soname}"
IFS=' ' # restore IFS
core="${arr[0]}.so"
ln -s ${soname} ${TBB_LIBDIR}/${core}.${arr[2]}
ln -s ${core}.${arr[2]} ${TBB_LIBDIR}/${core}
done
}
mkl_relink
tbb_relink
ldconfig
ok "Successfully installed mkl from PYPI"
......@@ -37,7 +37,7 @@ export LOCAL_HTTP_ADDR="http://172.17.0.1:8388"
if [[ "$(uname -m)" == "x86_64" ]]; then
if [[ "${APOLLO_DIST}" == "stable" ]]; then
export SUPPORTED_NVIDIA_SMS="3.7 5.2 6.0 6.1 7.0 7.5"
export SUPPORTED_NVIDIA_SMS="5.2 6.0 6.1 7.0 7.5"
else
export SUPPORTED_NVIDIA_SMS="5.2 6.0 6.1 7.0 7.5 8.0 8.6"
fi
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册