From 3c514fc2de74976172165803701d2a4247e40f5f Mon Sep 17 00:00:00 2001 From: Michael Mi Date: Fri, 28 Jun 2024 21:41:40 -0700 Subject: [PATCH] dev: fix issues in run_in_docker script (#254) * fix permission issues for run_in_docker script * exclude flashinfer to speed up build --- src/kernels/CMakeLists.txt | 2 +- tools/run_in_docker.sh | 32 +++++++++++++++----------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/kernels/CMakeLists.txt b/src/kernels/CMakeLists.txt index 397123cb..bd6e750d 100644 --- a/src/kernels/CMakeLists.txt +++ b/src/kernels/CMakeLists.txt @@ -73,5 +73,5 @@ cc_library( ) add_subdirectory(flash_attn) -add_subdirectory(flash_infer) +# add_subdirectory(flash_infer) diff --git a/tools/run_in_docker.sh b/tools/run_in_docker.sh index 20653be1..8f60afd5 100755 --- a/tools/run_in_docker.sh +++ b/tools/run_in_docker.sh @@ -1,16 +1,15 @@ #!/bin/bash -# adapted from https://github.com/tensorflow/serving +# Adapted from https://github.com/tensorflow/serving # ============================================================================== # # Script to run commands (like builds and scripts) in a docker container. # -# # Note: This script binds your working directory (via pwd) and /tmp to the # Docker container. Any scripts or programs you run will need to have its # output files/dirs written to one of the above locations for persistence. # -# Typical usage (to build from lastest upstream source): +# Typical usage (to build from latest upstream source): # $ git clone --recursive https://github.com/vectorch-ai/ScaleLLM.git # $ cd ScaleLLM # $ ./tools/run_in_docker.sh cmake -G Ninja -S . -B build @@ -51,29 +50,28 @@ RUN_OPTS+=("-v $(pwd):$(pwd)") RUN_OPTS+=("-v /tmp:/tmp") RUN_OPTS+=("-v ${HOME}:${HOME}") -# run as the current user -RUN_OPTS+=("-u $(id -u):$(id -g)") +# Carry over cache settings +VCPKG_DEFAULT_BINARY_CACHE=${VCPKG_DEFAULT_BINARY_CACHE:-${HOME}/.cache/vcpkg} +mkdir -p "${VCPKG_DEFAULT_BINARY_CACHE}" +RUN_OPTS+=("-v ${VCPKG_DEFAULT_BINARY_CACHE}:${VCPKG_DEFAULT_BINARY_CACHE}") +RUN_OPTS+=("-e VCPKG_DEFAULT_BINARY_CACHE=${VCPKG_DEFAULT_BINARY_CACHE}") -# carry over cache settings -if [[ -n "${VCPKG_DEFAULT_BINARY_CACHE}" ]]; then - mkdir -p ${VCPKG_DEFAULT_BINARY_CACHE} - RUN_OPTS+=("-v ${VCPKG_DEFAULT_BINARY_CACHE}:${VCPKG_DEFAULT_BINARY_CACHE}") - RUN_OPTS+=("-e VCPKG_DEFAULT_BINARY_CACHE=${VCPKG_DEFAULT_BINARY_CACHE}") -fi +CCACHE_DIR=${CCACHE_DIR:-${HOME}/.cache/ccache} +mkdir -p "${CCACHE_DIR}" +RUN_OPTS+=("-v ${CCACHE_DIR}:${CCACHE_DIR}") +RUN_OPTS+=("-e CCACHE_DIR=${CCACHE_DIR}") -if [[ -n "${CCACHE_DIR}" ]]; then - mkdir -p ${CCACHE_DIR} - RUN_OPTS+=("-v ${CCACHE_DIR}:${CCACHE_DIR}") - RUN_OPTS+=("-e CCACHE_DIR=${CCACHE_DIR}") -fi +# Run as the current user +RUN_OPTS+=("-u $(id -u):$(id -g)") CMD="$@" -[[ "${CMD}" = "" ]] && usage +[[ "${CMD}" == "" ]] && usage [[ ! -x $(command -v docker) ]] && echo "ERROR: 'docker' command missing from PATH." && usage if ! docker pull ${IMAGE}; then echo "WARNING: Failed to docker pull image ${IMAGE}" fi +# Execute the command in the Docker container # echo "docker run ${RUN_OPTS[@]} ${IMAGE} bash -c \"cd $(pwd); ${CMD}\"" docker run ${RUN_OPTS[@]} ${IMAGE} bash -c "cd $(pwd); ${CMD}"