mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-04-20 14:58:54 +00:00
Add gpuCI metafiles.
This commit is contained in:
39
ci/axis/gpu.yml
Normal file
39
ci/axis/gpu.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
# Copyright (c) 2018-2020 NVIDIA Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
# Released under the Apache License v2.0 with LLVM Exceptions.
|
||||
# See https://llvm.org/LICENSE.txt for license information.
|
||||
|
||||
SDK_TYPE:
|
||||
- cuda
|
||||
|
||||
SDK_VER:
|
||||
- 11.5.1-devel
|
||||
|
||||
OS_TYPE:
|
||||
- ubuntu
|
||||
|
||||
OS_VER:
|
||||
- 20.04
|
||||
|
||||
CXX_TYPE:
|
||||
- clang
|
||||
- gcc
|
||||
|
||||
CXX_VER:
|
||||
- 5
|
||||
- 6
|
||||
- 7
|
||||
- 8
|
||||
- 9
|
||||
- 10
|
||||
- 11
|
||||
- 12
|
||||
|
||||
exclude:
|
||||
- CXX_TYPE: clang
|
||||
CXX_VER:
|
||||
- 5
|
||||
- 6
|
||||
- CXX_TYPE: gcc
|
||||
CXX_VER:
|
||||
- 12
|
||||
231
ci/common/build.bash
Executable file
231
ci/common/build.bash
Executable file
@@ -0,0 +1,231 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2018-2020 NVIDIA Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
# Released under the Apache License v2.0 with LLVM Exceptions.
|
||||
# See https://llvm.org/LICENSE.txt for license information.
|
||||
|
||||
################################################################################
|
||||
# Thrust and CUB build script for gpuCI
|
||||
################################################################################
|
||||
|
||||
set -e
|
||||
|
||||
# append variable value
|
||||
# Appends ${value} to ${variable}, adding a space before ${value} if
|
||||
# ${variable} is not empty.
|
||||
function append {
|
||||
tmp="${!1:+${!1} }${2}"
|
||||
eval "${1}=\${tmp}"
|
||||
}
|
||||
|
||||
# log args...
|
||||
# Prints out ${args[*]} with a gpuCI log prefix and a newline before and after.
|
||||
function log() {
|
||||
printf "\n>>>> %s\n\n" "${*}"
|
||||
}
|
||||
|
||||
# print_with_trailing_blank_line args...
|
||||
# Prints ${args[*]} with one blank line following, preserving newlines within
|
||||
# ${args[*]} but stripping any preceding ${args[*]}.
|
||||
function print_with_trailing_blank_line {
|
||||
printf "%s\n\n" "${*}"
|
||||
}
|
||||
|
||||
# echo_and_run name args...
|
||||
# Echo ${args[@]}, then execute ${args[@]}
|
||||
function echo_and_run {
|
||||
echo "${1}: ${@:2}"
|
||||
${@:2}
|
||||
}
|
||||
|
||||
# echo_and_run_timed name args...
|
||||
# Echo ${args[@]}, then execute ${args[@]} and report how long it took,
|
||||
# including ${name} in the output of the time.
|
||||
function echo_and_run_timed {
|
||||
echo "${@:2}"
|
||||
TIMEFORMAT=$'\n'"${1} Time: %lR"
|
||||
time ${@:2}
|
||||
}
|
||||
|
||||
# join_delimit <delimiter> [value [value [...]]]
|
||||
# Combine all values into a single string, separating each by a single character
|
||||
# delimiter. Eg:
|
||||
# foo=(bar baz kramble)
|
||||
# joined_foo=$(join_delimit "|" "${foo[@]}")
|
||||
# echo joined_foo # "bar|baz|kramble"
|
||||
function join_delimit {
|
||||
local IFS="${1}"
|
||||
shift
|
||||
echo "${*}"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# VARIABLES - Set up bash and environmental variables.
|
||||
################################################################################
|
||||
|
||||
# Get the variables the Docker container set up for us: ${CXX}, ${CUDACXX}, etc.
|
||||
source /etc/cccl.bashrc
|
||||
|
||||
# Set path.
|
||||
export PATH=/usr/local/cuda/bin:${PATH}
|
||||
|
||||
# Set home to the job's workspace.
|
||||
export HOME=${WORKSPACE}
|
||||
|
||||
# Switch to the build directory.
|
||||
cd ${WORKSPACE}
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
# Remove any old .ninja_log file so the PrintNinjaBuildTimes step is accurate:
|
||||
rm -f .ninja_log
|
||||
|
||||
if [[ -z "${CMAKE_BUILD_TYPE}" ]]; then
|
||||
CMAKE_BUILD_TYPE="Release"
|
||||
fi
|
||||
|
||||
CMAKE_BUILD_FLAGS="--"
|
||||
|
||||
# The Docker image sets up `${CXX}` and `${CUDACXX}`.
|
||||
append CMAKE_FLAGS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
|
||||
append CMAKE_FLAGS "-DCMAKE_CUDA_COMPILER='${CUDACXX}'"
|
||||
|
||||
if [[ "${CXX_TYPE}" == "nvcxx" ]]; then
|
||||
echo "nvc++ not supported."
|
||||
exit 1
|
||||
else
|
||||
if [[ "${CXX_TYPE}" == "icc" ]]; then
|
||||
echo "icc not supported."
|
||||
exit 1
|
||||
fi
|
||||
# We're using NVCC so we need to set the host compiler.
|
||||
append CMAKE_FLAGS "-DCMAKE_CXX_COMPILER='${CXX}'"
|
||||
append CMAKE_FLAGS "-DCMAKE_CUDA_HOST_COMPILER='${CXX}'"
|
||||
append CMAKE_FLAGS "-G Ninja"
|
||||
# Don't stop on build failures.
|
||||
append CMAKE_BUILD_FLAGS "-k0"
|
||||
fi
|
||||
|
||||
if [[ -n "${PARALLEL_LEVEL}" ]]; then
|
||||
DETERMINE_PARALLELISM_FLAGS="-j ${PARALLEL_LEVEL}"
|
||||
fi
|
||||
|
||||
WSL=0
|
||||
if [[ $(grep -i microsoft /proc/version) ]]; then
|
||||
echo "Windows Subsystem for Linux detected."
|
||||
WSL=1
|
||||
fi
|
||||
export WSL
|
||||
|
||||
#append CMAKE_FLAGS "-DCMAKE_CUDA_ARCHITECTURES=all"
|
||||
|
||||
append CMAKE_FLAGS "-DNVBench_ENABLE_EXAMPLES=ON"
|
||||
append CMAKE_FLAGS "-DNVBench_ENABLE_TESTING=ON"
|
||||
append CMAKE_FLAGS "-DNVBench_ENABLE_CUPTI=ON"
|
||||
append CMAKE_FLAGS "-DNVBench_ENABLE_WERROR=ON"
|
||||
|
||||
# These consume a lot of time and don't currently have
|
||||
# any value as regression tests.
|
||||
append CMAKE_FLAGS "-DNVBench_ENABLE_DEVICE_TESTING=OFF"
|
||||
|
||||
# NVML doesn't work under WSL
|
||||
if [[ ${WSL} -eq 0 ]]; then
|
||||
append CMAKE_FLAGS "-DNVBench_ENABLE_NVML=ON"
|
||||
else
|
||||
append CMAKE_FLAGS "-DNVBench_ENABLE_NVML=OFF"
|
||||
fi
|
||||
|
||||
if [[ -n "${@}" ]]; then
|
||||
append CMAKE_BUILD_FLAGS "${@}"
|
||||
fi
|
||||
|
||||
append CTEST_FLAGS "--output-on-failure"
|
||||
|
||||
# Export variables so they'll show up in the logs when we report the environment.
|
||||
export CMAKE_FLAGS
|
||||
export CMAKE_BUILD_FLAGS
|
||||
export CTEST_FLAGS
|
||||
|
||||
################################################################################
|
||||
# ENVIRONMENT - Configure and print out information about the environment.
|
||||
################################################################################
|
||||
|
||||
log "Determine system topology..."
|
||||
|
||||
# Set `${PARALLEL_LEVEL}` if it is unset; otherwise, this just reports the
|
||||
# system topology.
|
||||
source ${WORKSPACE}/ci/common/determine_build_parallelism.bash ${DETERMINE_PARALLELISM_FLAGS}
|
||||
|
||||
log "Get environment..."
|
||||
|
||||
env | sort
|
||||
|
||||
log "Check versions..."
|
||||
|
||||
# We use sed and echo below to ensure there is always one and only trailing
|
||||
# line following the output from each tool.
|
||||
|
||||
${CXX} --version 2>&1 | sed -Ez '$ s/\n*$/\n/'
|
||||
|
||||
echo
|
||||
|
||||
${CUDACXX} --version 2>&1 | sed -Ez '$ s/\n*$/\n/'
|
||||
|
||||
echo
|
||||
|
||||
cmake --version 2>&1 | sed -Ez '$ s/\n*$/\n/'
|
||||
|
||||
echo
|
||||
|
||||
if [[ "${BUILD_TYPE}" == "gpu" ]]; then
|
||||
nvidia-smi 2>&1 | sed -Ez '$ s/\n*$/\n/'
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
# BUILD
|
||||
################################################################################
|
||||
|
||||
log "Configure..."
|
||||
|
||||
echo_and_run_timed "Configure" cmake .. --log-level=VERBOSE ${CMAKE_FLAGS}
|
||||
configure_status=$?
|
||||
|
||||
log "Build..."
|
||||
|
||||
# ${PARALLEL_LEVEL} needs to be passed after we run
|
||||
# determine_build_parallelism.bash, so it can't be part of ${CMAKE_BUILD_FLAGS}.
|
||||
set +e # Don't stop on build failures.
|
||||
echo_and_run_timed "Build" cmake --build . ${CMAKE_BUILD_FLAGS} -j ${PARALLEL_LEVEL}
|
||||
build_status=$?
|
||||
set -e
|
||||
|
||||
################################################################################
|
||||
# TEST - Run examples and tests.
|
||||
################################################################################
|
||||
|
||||
log "Test..."
|
||||
|
||||
(
|
||||
# Make sure test_status captures ctest, not tee:
|
||||
# https://stackoverflow.com/a/999259/11130318
|
||||
set -o pipefail
|
||||
echo_and_run_timed "Test" ctest ${CTEST_FLAGS} | tee ctest_log
|
||||
)
|
||||
|
||||
test_status=$?
|
||||
|
||||
################################################################################
|
||||
# SUMMARY - Print status of each step and exit with failure if needed.
|
||||
################################################################################
|
||||
|
||||
log "Summary:"
|
||||
echo "- Configure Error Code: ${configure_status}"
|
||||
echo "- Build Error Code: ${build_status}"
|
||||
echo "- Test Error Code: ${test_status}"
|
||||
|
||||
if [[ "${configure_status}" != "0" ]] || \
|
||||
[[ "${build_status}" != "0" ]] || \
|
||||
[[ "${test_status}" != "0" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
119
ci/common/determine_build_parallelism.bash
Executable file
119
ci/common/determine_build_parallelism.bash
Executable file
@@ -0,0 +1,119 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2018-2020 NVIDIA Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
# Released under the Apache License v2.0 with LLVM Exceptions.
|
||||
# See https://llvm.org/LICENSE.txt for license information.
|
||||
|
||||
function usage {
|
||||
echo "Usage: ${0} [flags...]"
|
||||
echo
|
||||
echo "Examine the system topology to determine a reasonable amount of build"
|
||||
echo "parallelism."
|
||||
echo
|
||||
echo "Exported variables:"
|
||||
echo " \${LOGICAL_CPUS} : Logical processors (e.g. threads)."
|
||||
echo " \${PHYSICAL_CPUS} : Physical processors (e.g. cores)."
|
||||
echo " \${TOTAL_MEM} : Total system memory [GB]."
|
||||
echo " \${MAX_THREADS_PER_CORE} : Maximum threads per core allowed."
|
||||
echo " \${MIN_MEMORY_PER_THREAD} : Minimum memory [GB] per thread allowed."
|
||||
echo " \${CPU_BOUND_THREADS} : # of build threads constrained by processors."
|
||||
echo " \${MEM_BOUND_THREADS} : # of build threads constrained by memory [GB]."
|
||||
echo " \${PARALLEL_LEVEL} : Determined # of build threads."
|
||||
echo " \${MEM_PER_THREAD} : Memory [GB] per build thread."
|
||||
echo
|
||||
echo "-h, -help, --help"
|
||||
echo " Print this message."
|
||||
echo
|
||||
echo "-q, --quiet"
|
||||
echo " Print nothing and only export variables."
|
||||
echo
|
||||
echo "-j <threads>, --jobs <threads>"
|
||||
echo " Explicitly set the number of build threads to use."
|
||||
echo
|
||||
echo "--max-threads-per-core <threads>"
|
||||
echo " Specify the maximum threads per core allowed (default: ${MAX_THREADS_PER_CORE} [threads/core])."
|
||||
echo
|
||||
echo "--min-memory-per-thread <gigabytes>"
|
||||
echo " Specify the minimum memory per thread allowed (default: ${MIN_MEMORY_PER_THREAD} [GBs/thread])."
|
||||
|
||||
exit -3
|
||||
}
|
||||
|
||||
QUIET=0
|
||||
|
||||
export MAX_THREADS_PER_CORE=2
|
||||
export MIN_MEMORY_PER_THREAD=1 # [GB]
|
||||
|
||||
while test ${#} != 0
|
||||
do
|
||||
case "${1}" in
|
||||
-h) ;&
|
||||
-help) ;&
|
||||
--help) usage ;;
|
||||
-q) ;&
|
||||
--quiet) QUIET=1 ;;
|
||||
-j) ;&
|
||||
--jobs)
|
||||
shift # The next argument is the number of threads.
|
||||
PARALLEL_LEVEL="${1}"
|
||||
;;
|
||||
--max-threads-per-core)
|
||||
shift # The next argument is the number of threads per core.
|
||||
MAX_THREADS_PER_CORE="${1}"
|
||||
;;
|
||||
--min-memory-per-thread)
|
||||
shift # The next argument is the amount of memory per thread.
|
||||
MIN_MEMORY_PER_THREAD="${1}"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# https://stackoverflow.com/a/23378780
|
||||
if [ $(uname) == "Darwin" ]; then
|
||||
export LOGICAL_CPUS=$(sysctl -n hw.logicalcpu_max)
|
||||
export PHYSICAL_CPUS=$(sysctl -n hw.physicalcpu_max)
|
||||
else
|
||||
export LOGICAL_CPUS=$(lscpu -p | egrep -v '^#' | wc -l)
|
||||
export PHYSICAL_CPUS=$(lscpu -p | egrep -v '^#' | sort -u -t, -k 2,4 | wc -l)
|
||||
fi
|
||||
|
||||
export TOTAL_MEM=$(awk "BEGIN { printf \"%0.4g\", $(grep MemTotal /proc/meminfo | awk '{ print $2 }') / (1024 * 1024) }")
|
||||
|
||||
export CPU_BOUND_THREADS=$(awk "BEGIN { printf \"%.04g\", int(${PHYSICAL_CPUS} * ${MAX_THREADS_PER_CORE}) }")
|
||||
export MEM_BOUND_THREADS=$(awk "BEGIN { printf \"%.04g\", int(${TOTAL_MEM} / ${MIN_MEMORY_PER_THREAD}) }")
|
||||
|
||||
if [[ -z "${PARALLEL_LEVEL}" ]]; then
|
||||
# Pick the smaller of the two as the default.
|
||||
if [[ "${MEM_BOUND_THREADS}" -lt "${CPU_BOUND_THREADS}" ]]; then
|
||||
export PARALLEL_LEVEL=${MEM_BOUND_THREADS}
|
||||
else
|
||||
export PARALLEL_LEVEL=${CPU_BOUND_THREADS}
|
||||
fi
|
||||
else
|
||||
EXPLICIT_PARALLEL_LEVEL=1
|
||||
fi
|
||||
|
||||
# This can be a floating point number.
|
||||
export MEM_PER_THREAD=$(awk "BEGIN { printf \"%.04g\", ${TOTAL_MEM} / ${PARALLEL_LEVEL} }")
|
||||
|
||||
if [[ "${QUIET}" == 0 ]]; then
|
||||
echo "Logical CPUs: ${LOGICAL_CPUS} [threads]"
|
||||
echo "Physical CPUs: ${PHYSICAL_CPUS} [cores]"
|
||||
echo "Total Mem: ${TOTAL_MEM} [GBs]"
|
||||
echo "Max Threads Per Core: ${MAX_THREADS_PER_CORE} [threads/core]"
|
||||
echo "Min Memory Per Threads: ${MIN_MEMORY_PER_THREAD} [GBs/thread]"
|
||||
echo "CPU Bound Threads: ${CPU_BOUND_THREADS} [threads]"
|
||||
echo "Mem Bound Threads: ${MEM_BOUND_THREADS} [threads]"
|
||||
|
||||
echo -n "Parallel Level: ${PARALLEL_LEVEL} [threads]"
|
||||
if [[ -n "${EXPLICIT_PARALLEL_LEVEL}" ]]; then
|
||||
echo " (explicitly set)"
|
||||
else
|
||||
echo
|
||||
fi
|
||||
|
||||
echo "Mem Per Thread: ${MEM_PER_THREAD} [GBs/thread]"
|
||||
fi
|
||||
|
||||
14
ci/gpu/build.bash
Executable file
14
ci/gpu/build.bash
Executable file
@@ -0,0 +1,14 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2018-2020 NVIDIA Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
# Released under the Apache License v2.0 with LLVM Exceptions.
|
||||
# See https://llvm.org/LICENSE.txt for license information.
|
||||
|
||||
################################################################################
|
||||
# Thrust and CUB build script for gpuCI (heterogeneous)
|
||||
################################################################################
|
||||
|
||||
export PARALLEL_LEVEL=${PARALLEL_LEVEL:-4}
|
||||
|
||||
source ${WORKSPACE}/ci/common/build.bash
|
||||
215
ci/local/build.bash
Executable file
215
ci/local/build.bash
Executable file
@@ -0,0 +1,215 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2018-2020 NVIDIA Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
# Released under the Apache License v2.0 with LLVM Exceptions.
|
||||
# See https://llvm.org/LICENSE.txt for license information.
|
||||
|
||||
################################################################################
|
||||
# Thrust and CUB local containerized build script
|
||||
################################################################################
|
||||
|
||||
function usage {
|
||||
echo "Usage: ${0} [flags...] [cmake-targets...]"
|
||||
echo
|
||||
echo "Build and test your local repository using a gpuCI Docker image."
|
||||
echo "If CMake targets are specified, only those targets are built and tested."
|
||||
echo "Otherwise, everything is built and tested."
|
||||
echo
|
||||
echo "-h, -help, --help"
|
||||
echo " Print this message."
|
||||
echo
|
||||
echo "-r <path>, --repository <path>"
|
||||
echo " Path to the repository (default: ${REPOSITORY_PATH})."
|
||||
echo
|
||||
echo "-i <image>, --image <image>"
|
||||
echo " Docker image to use (default: ${IMAGE})"
|
||||
echo
|
||||
echo "-l, --local-image"
|
||||
echo " Use the local version of the image instead of pulling from Docker hub."
|
||||
echo
|
||||
echo "-s, --shell-only"
|
||||
echo " Skip building and testing and launch an interactive shell instead."
|
||||
echo
|
||||
echo "-d, --disable-gpus"
|
||||
echo " Don't start the container with the NVIDIA runtime and GPUs attached."
|
||||
echo
|
||||
echo "-c, --clean"
|
||||
echo " If the build directory already exists, delete it."
|
||||
echo
|
||||
echo "-j <threads>, --jobs <threads>"
|
||||
echo " Number of threads to use when building (default: inferred)."
|
||||
echo
|
||||
echo "-b <type>, --cmake-build-type <plan>"
|
||||
echo " CMake build type to use, either Release, RelWithDebInfo, or Debug"
|
||||
echo " (default: ${CMAKE_BUILD_TYPE})."
|
||||
echo
|
||||
|
||||
exit -3
|
||||
}
|
||||
|
||||
SCRIPT_PATH=$(cd $(dirname ${0}); pwd -P)
|
||||
|
||||
REPOSITORY_PATH=$(realpath ${SCRIPT_PATH}/../..)
|
||||
|
||||
################################################################################
|
||||
# FLAGS - Process command line flags.
|
||||
################################################################################
|
||||
|
||||
IMAGE="gpuci/cccl:cuda11.5.1-devel-ubuntu20.04-gcc7"
|
||||
|
||||
LOCAL_IMAGE=0
|
||||
|
||||
SHELL_ONLY=0
|
||||
|
||||
BUILD_TYPE="gpu"
|
||||
|
||||
CLEAN=0
|
||||
|
||||
PARALLEL_LEVEL=""
|
||||
|
||||
CMAKE_BUILD_TYPE="Release"
|
||||
|
||||
TARGETS=""
|
||||
|
||||
while test ${#} != 0
|
||||
do
|
||||
case "${1}" in
|
||||
-h) ;&
|
||||
-help) ;&
|
||||
--help) usage ;;
|
||||
-r) ;&
|
||||
--repository)
|
||||
shift # The next argument is the path.
|
||||
REPOSITORY_PATH="${1}"
|
||||
;;
|
||||
-i) ;&
|
||||
--image)
|
||||
shift # The next argument is the image.
|
||||
IMAGE="${1}"
|
||||
;;
|
||||
-l) ;&
|
||||
--local-image) LOCAL_IMAGE=1 ;;
|
||||
-s) ;&
|
||||
--shell-only) SHELL_ONLY=1 ;;
|
||||
-d) ;&
|
||||
--disable-gpus) BUILD_TYPE="cpu" ;;
|
||||
-c) ;&
|
||||
--clean) CLEAN=1 ;;
|
||||
-j) ;&
|
||||
--jobs)
|
||||
shift # The next argument is the number of threads.
|
||||
PARALLEL_LEVEL="${1}"
|
||||
;;
|
||||
-b) ;&
|
||||
--cmake-build-type)
|
||||
shift # The next argument is the build type.
|
||||
CMAKE_BUILD_TYPE="${1}"
|
||||
;;
|
||||
*)
|
||||
TARGETS="${TARGETS:+${TARGETS} }${1}"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
################################################################################
|
||||
# PATHS - Setup paths for the container.
|
||||
################################################################################
|
||||
|
||||
# ${REPOSITORY_PATH} is the local filesystem path to the Git repository being
|
||||
# built and tested. It can be set with the --repository flag.
|
||||
#
|
||||
# ${BUILD_PATH} is the local filesystem path that will be used for the build. It
|
||||
# is named after the image name, allowing multiple image builds to coexist on
|
||||
# the local filesystem.
|
||||
#
|
||||
# ${REPOSITORY_PATH_IN_CONTAINER} is the location of ${REPOSITORY_PATH} inside
|
||||
# the container.
|
||||
#
|
||||
# ${BUILD_PATH_IN_CONTAINER} is the location of ${BUILD_PATH} inside the
|
||||
# container.
|
||||
|
||||
BUILD_PATH=${REPOSITORY_PATH}/build_$(echo "$(basename "${IMAGE}")" | sed -e 's/:/_/g' | sed -e 's/-/_/g')
|
||||
|
||||
if [[ "${CLEAN}" != 0 ]]; then
|
||||
rm -rf ${BUILD_PATH}
|
||||
fi
|
||||
|
||||
mkdir -p ${BUILD_PATH}
|
||||
|
||||
BASE_PATH_IN_CONTAINER="/cccl"
|
||||
|
||||
REPOSITORY_PATH_IN_CONTAINER="${BASE_PATH_IN_CONTAINER}/$(basename "${REPOSITORY_PATH}")"
|
||||
|
||||
BUILD_PATH_IN_CONTAINER="${BASE_PATH_IN_CONTAINER}/$(basename "${REPOSITORY_PATH}")/build"
|
||||
|
||||
################################################################################
|
||||
# ENVIRONMENT - Setup the thunk build script that will be run by the container.
|
||||
################################################################################
|
||||
|
||||
# We have to run `ldconfig` to rebuild `ld.so.cache` to work around this
|
||||
# failure on Debian: https://github.com/NVIDIA/nvidia-docker/issues/1399
|
||||
|
||||
COMMAND="sudo ldconfig; sudo ldconfig"
|
||||
if [[ "${SHELL_ONLY}" != 0 ]]; then
|
||||
COMMAND="${COMMAND}; bash"
|
||||
else
|
||||
COMMAND="${COMMAND}; ${REPOSITORY_PATH_IN_CONTAINER}/ci/common/build.bash ${TARGETS} || bash"
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
# GPU - Setup GPUs.
|
||||
################################################################################
|
||||
|
||||
# Note: We always start docker with --gpus, even for cpu builds. Otherwise
|
||||
# libcuda.so.1 is not present and no NVBench tests are able to run.
|
||||
|
||||
# Limit GPUs available to the container based on ${CUDA_VISIBLE_DEVICES}.
|
||||
if [[ -z "${CUDA_VISIBLE_DEVICES}" ]]; then
|
||||
VISIBLE_DEVICES="all"
|
||||
else
|
||||
VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES}"
|
||||
fi
|
||||
|
||||
DOCKER_MAJOR_VER=$(docker -v | sed 's/[^[0-9]*\([0-9]*\).*/\1/')
|
||||
GPU_OPTS="--gpus device=${VISIBLE_DEVICES}"
|
||||
if [[ "${DOCKER_MAJOR_VER}" -lt 19 ]]
|
||||
then
|
||||
GPU_OPTS="--runtime=nvidia -e NVIDIA_VISIBLE_DEVICES='${VISIBLE_DEVICES}'"
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
# LAUNCH - Pull and launch the container.
|
||||
################################################################################
|
||||
|
||||
#NVIDIA_DOCKER_INSTALLED=$(docker info 2>&1 | grep -i runtime | grep -c nvidia)
|
||||
NVIDIA_DOCKER_INSTALLED=1 # Broken on WSL
|
||||
if [[ "${NVIDIA_DOCKER_INSTALLED}" == 0 ]]; then
|
||||
echo "NVIDIA Docker not found, please install it: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#installing-docker-ce"
|
||||
exit -4
|
||||
fi
|
||||
|
||||
if [[ "${LOCAL_IMAGE}" == 0 ]]; then
|
||||
docker pull "${IMAGE}"
|
||||
fi
|
||||
|
||||
docker run --rm -it ${GPU_OPTS} \
|
||||
--cap-add=SYS_PTRACE \
|
||||
--user "$(id -u)":"$(id -g)" \
|
||||
-v "${REPOSITORY_PATH}":"${REPOSITORY_PATH_IN_CONTAINER}" \
|
||||
-v "${BUILD_PATH}":"${BUILD_PATH_IN_CONTAINER}" \
|
||||
-v /etc/passwd:/etc/passwd:ro \
|
||||
-v /etc/group:/etc/group:ro \
|
||||
-v /etc/subuid:/etc/subuid:ro \
|
||||
-v /etc/subgid:/etc/subgid:ro \
|
||||
-v /etc/shadow:/etc/shadow:ro \
|
||||
-v /etc/gshadow:/etc/gshadow:ro \
|
||||
-e "WORKSPACE=${REPOSITORY_PATH_IN_CONTAINER}" \
|
||||
-e "BUILD_TYPE=${BUILD_TYPE}" \
|
||||
-e "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" \
|
||||
-e "COVERAGE_PLAN=${COVERAGE_PLAN}" \
|
||||
-e "PARALLEL_LEVEL=${PARALLEL_LEVEL}" \
|
||||
-w "${BUILD_PATH_IN_CONTAINER}" \
|
||||
"${IMAGE}" bash -c "${COMMAND}"
|
||||
|
||||
Reference in New Issue
Block a user