Skip to content

Commit

Permalink
Bazel: apollo.sh config interactive mode simplified and improved
Browse files Browse the repository at this point in the history
  • Loading branch information
storypku authored and xiaoxq committed Sep 13, 2020
1 parent 15c77cb commit 1ab0dca
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 537 deletions.
4 changes: 2 additions & 2 deletions docker/build/installers/installer_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export APOLLO_LD_FILE="/etc/ld.so.conf.d/apollo.conf"
export DOWNLOAD_LOG="/opt/apollo/build.log"
export LOCAL_HTTP_ADDR="http://172.17.0.1:8388"

# export SUPPORTED_NVIDIA_SMS="5.0 5.2 6.0 6.1 7.0 7.2 7.5"
export SUPPORTED_NVIDIA_SMS="5.0 6.0 6.1 7.0 7.2 7.5"
# export SUPPORTED_NVIDIA_SMS="3.7 5.0 5.2 6.0 6.1 7.0 7.2 7.5"
export SUPPORTED_NVIDIA_SMS="3.7 5.2 6.0 6.1 7.0 7.2 7.5"

function py3_version() {
local version
Expand Down
24 changes: 9 additions & 15 deletions scripts/apollo_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@

TOP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
source "${TOP_DIR}/cyber/setup.bash"
# STAGE="${STAGE:-dev}"
: ${STAGE:=dev}

IFS='' read -r -d '' STARTUP_TXT << EOF
startup --output_user_root="${APOLLO_CACHE_DIR}/bazel"
common --distdir="${APOLLO_BAZEL_DISTDIR}"
EOF

set -e

Expand All @@ -33,23 +26,24 @@ BAZEL_CONF="${TOP_DIR}/.apollo.bazelrc"
ARCH="$(uname -m)"

function config_noninteractive() {
echo "${STARTUP_TXT}" > "${BAZEL_CONF}"
local output_dir="${APOLLO_CACHE_DIR}/bazel"

> "${BAZEL_CONF}"
echo "startup --output_user_root=\"${output_dir}\"" >> "${BAZEL_CONF}"
echo "common --distdir=\"${APOLLO_BAZEL_DISTDIR}\"" >> "${BAZEL_CONF}"
echo >> "${BAZEL_CONF}"

echo -e "build --action_env GCC_HOST_COMPILER_PATH=\"/usr/bin/${ARCH}-linux-gnu-gcc-7\"" >> "${BAZEL_CONF}"
cat "${TOP_DIR}/tools/apollo.bazelrc.sample" >> "${BAZEL_CONF}"
}

function config_interactive() {
if [ -z "$PYTHON_BIN_PATH" ]; then
PYTHON_BIN_PATH=$(which python3 || true)
fi

py3_bin="$(which python3 || true)"
# Set all env variables
"$PYTHON_BIN_PATH" "${TOP_DIR}/tools/bootstrap.py" "$@"
echo "${STARTUP_TXT}" >> "${BAZEL_CONF}"
"${py3_bin}" "${TOP_DIR}/tools/bootstrap.py" "$@"
}

function config() {
local stage="${STAGE}"
if [ $# -eq 0 ]; then
config_noninteractive
else
Expand Down
19 changes: 4 additions & 15 deletions tools/apollo.bazelrc.sample
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
build --action_env CUDA_TOOLKIT_PATH="/usr/local/cuda-10.2"
build --action_env TF_CUDA_COMPUTE_CAPABILITIES="5.2,6.0,6.1,7.0,7.2,7.5"

build --action_env PYTHON_BIN_PATH="/usr/bin/python3"
build --action_env PYTHON_LIB_PATH="/usr/lib/python3/dist-packages"
build --python_path="/usr/bin/python3"

build:gpu --config=cuda
build:gpu --config=tensorrt

## The following was adapted from tensorflow/.bazelrc
build --action_env CUDA_TOOLKIT_PATH="/usr/local/cuda-10.2"
build --action_env TF_CUDA_COMPUTE_CAPABILITIES="3.7,5.2,6.0,6.1,7.0,7.2,7.5"

# This config refers to building with CUDA available. It does not necessarily
# mean that we build CUDA op kernels.
# This config refers to building with CUDA available.
build:using_cuda --define=using_cuda=true
build:using_cuda --action_env TF_NEED_CUDA=1
build:using_cuda --crosstool_top=@local_config_cuda//crosstool:toolchain

# This config refers to building CUDA op kernels with nvcc.
# This config refers to building CUDA with nvcc.
build:cuda --config=using_cuda
build:cuda --define=using_cuda_nvcc=true

# This config refers to building CUDA op kernels with clang.
build:cuda_clang --config=using_cuda
build:cuda_clang --define=using_cuda_clang=true
build:cuda_clang --define=using_clang=true
build:cuda_clang --action_env TF_CUDA_CLANG=1

build:tensorrt --action_env TF_NEED_TENSORRT=1
build:nonccl --define=no_nccl_support=true

build:teleop --define=WITH_TELEOP=true
Loading

0 comments on commit 1ab0dca

Please sign in to comment.