Skip to content

Commit 6fd8800

Browse files
committed
Add a script to configure the sccache client to use the build cluster
1 parent 099eeb2 commit 6fd8800

File tree

16 files changed

+320
-66
lines changed

16 files changed

+320
-66
lines changed

.devcontainer/cuda11.8-conda/devcontainer.json

+5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@
1515
],
1616
"hostRequirements": {"gpu": "optional"},
1717
"features": {
18+
"./features/src/sccache": {
19+
"repository": "trxcllnt/sccache",
20+
"version": "0.10.0-rapids.1"
21+
},
1822
"./features/src/utils": {},
1923
"./features/src/rapids-build-utils": {}
2024
},
2125
"overrideFeatureInstallOrder": [
26+
"./features/src/sccache",
2227
"./features/src/utils",
2328
"./features/src/rapids-build-utils"
2429
],

.devcontainer/cuda11.8-pip/devcontainer.json

+5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@
2424
"installcuRAND": true,
2525
"installcuSPARSE": true
2626
},
27+
"./features/src/sccache": {
28+
"repository": "trxcllnt/sccache",
29+
"version": "0.10.0-rapids.1"
30+
},
2731
"./features/src/utils": {},
2832
"./features/src/rapids-build-utils": {}
2933
},
3034
"overrideFeatureInstallOrder": [
3135
"./features/src/cuda",
36+
"./features/src/sccache",
3237
"./features/src/utils",
3338
"./features/src/rapids-build-utils"
3439
],

.devcontainer/cuda12.8-conda/devcontainer.json

+5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@
3737
"installnvJPEG": false,
3838
"pruneStaticLibs": true
3939
},
40+
"./features/src/sccache": {
41+
"repository": "trxcllnt/sccache",
42+
"version": "0.10.0-rapids.1"
43+
},
4044
"./features/src/utils": {},
4145
"./features/src/rapids-build-utils": {}
4246
},
4347
"overrideFeatureInstallOrder": [
4448
"./features/src/cuda",
49+
"./features/src/sccache",
4550
"./features/src/utils",
4651
"./features/src/rapids-build-utils"
4752
],

.devcontainer/cuda12.8-pip/devcontainer.json

+5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@
2525
"installcuSPARSE": true,
2626
"installProfilers": true
2727
},
28+
"./features/src/sccache": {
29+
"repository": "trxcllnt/sccache",
30+
"version": "0.10.0-rapids.1"
31+
},
2832
"./features/src/utils": {},
2933
"./features/src/rapids-build-utils": {}
3034
},
3135
"overrideFeatureInstallOrder": [
3236
"./features/src/cuda",
37+
"./features/src/sccache",
3338
"./features/src/utils",
3439
"./features/src/rapids-build-utils"
3540
],

.devcontainer/rapids.Dockerfile

+10-1
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,18 @@ ENV PYTHONDONTWRITEBYTECODE="1"
4949

5050
ENV SCCACHE_REGION="us-east-2"
5151
ENV SCCACHE_BUCKET="rapids-sccache-devs"
52-
ENV SCCACHE_IDLE_TIMEOUT=900
52+
ENV SCCACHE_DIST_SCHEDULER_URL="https://amd64.linux.sccache.gha-runners.nvidia.com"
53+
ENV SCCACHE_IDLE_TIMEOUT=1800
5354
ENV AWS_ROLE_ARN="arn:aws:iam::279114543810:role/nv-gha-token-sccache-devs"
5455

5556
ENV HISTFILE="/home/coder/.cache/._bash_history"
5657

5758
ENV LIBCUDF_KERNEL_CACHE_PATH="/home/coder/cudf/cpp/build/${PYTHON_PACKAGE_MANAGER}/cuda-${CUDA_VERSION}/latest/jitify_cache"
59+
60+
# Prevent the sccache server from shutting down
61+
ENV SCCACHE_IDLE_TIMEOUT=0
62+
ENV SCCACHE_SERVER_LOG="sccache=debug"
63+
ENV SCCACHE_S3_KEY_PREFIX=rapids-test-sccache-dist
64+
# Build as much in parallel as possible
65+
ENV INFER_NUM_DEVICE_ARCHITECTURES=1
66+
ENV MAX_DEVICE_OBJ_TO_COMPILE_IN_PARALLEL=20

.github/workflows/build-all-rapids-repos.yml

+32-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
if: needs.check-event.outputs.ok == 'true'
2828
needs: check-event
2929
secrets: inherit
30-
uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.04
30+
uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@rapids-aux-secret-input
3131
permissions:
3232
actions: read
3333
packages: read
@@ -37,22 +37,48 @@ jobs:
3737
with:
3838
arch: '["amd64"]'
3939
cuda: '["12.8"]'
40-
node_type: cpu32
40+
node_type: cpu4
4141
extra-repo-deploy-key: CUMLPRIMS_SSH_PRIVATE_DEPLOY_KEY
42+
rapids-aux-secret-1: GIST_REPO_READ_ORG_GITHUB_TOKEN
4243
build_command: |
44+
# Stop the sccache client
45+
SCCACHE_NO_DAEMON=1 sccache --stop-server;
46+
47+
# Write the sccache client build cluster configuration
48+
devcontainer-utils-configure-sccache-dist - <<< "--auth-type 'token' --auth-token '$RAPIDS_AUX_SECRET_1'";
49+
50+
# Prevent the sccache server from shutting down
4351
export SCCACHE_IDLE_TIMEOUT=0
44-
SCCACHE_NO_DAEMON=1 sccache --stop-server
45-
sccache -z;
46-
sccache --show-adv-stats;
52+
53+
# Disable CUB/Thrust arch-dependent namespaces, since this prevents
54+
# reusing ptx and cubins from mult-iarch compilations in single-arch
55+
# subset compilations.
56+
for VAR in CFLAGS CXXFLAGS CUDAFLAGS; do
57+
export "$VAR=${!VAR:+${!VAR} }-DCUB_DISABLE_NAMESPACE_MAGIC -DCUB_IGNORE_NAMESPACE_MAGIC_ERROR"
58+
export "$VAR=${!VAR:+${!VAR} }-DTHRUST_DISABLE_ABI_NAMESPACE -DTHRUST_IGNORE_ABI_NAMESPACE_ERROR"
59+
done
60+
61+
# Restart the sccache client with the new configuration
62+
sccache --start-server;
63+
64+
# Verify cache and dist configuration
65+
sccache -s;
66+
devcontainer-utils-sccache-dist-status -c 10 -f tsv;
67+
68+
# Clone all the repos
4769
clone-all -j$(nproc) -v -q --clone-upstream --single-branch --shallow-submodules;
70+
71+
# Build all the repos
4872
build-all \
4973
-v \
50-
-j$(nproc --ignore=1) \
74+
-j64 \
5175
-DBUILD_SHARED_LIBS=ON \
5276
-DBUILD_TESTS=ON \
5377
-DBUILD_BENCHMARKS=ON \
5478
-DBUILD_PRIMS_BENCH=ON \
5579
-DRAFT_COMPILE_LIBRARY=ON \
5680
-DBUILD_CUGRAPH_MG_TESTS=ON \
5781
;
82+
83+
# Print cache and dist stats
5884
sccache --show-adv-stats;

features/src/rapids-build-utils/devcontainer-feature.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "NVIDIA RAPIDS devcontainer build utilities",
33
"id": "rapids-build-utils",
4-
"version": "25.4.4",
4+
"version": "25.4.5",
55
"description": "A feature to install the RAPIDS devcontainer build utilities",
66
"containerEnv": {
77
"BASH_ENV": "/etc/bash.bash_env"

features/src/rapids-build-utils/opt/rapids-build-utils/bin/get-num-archs-jobs-and-load.sh

+7-55
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
# rapids-get-num-archs-jobs-and-load [OPTION]...
55
#
66
# Compute an appropriate total number of jobs, load, and CUDA archs to build in parallel.
7-
# This routine scales the input `-j` with respect to the `-a` and `-m` values, taking into account the
8-
# amount of available system memory (free mem + swap), in order to balance the job and arch parallelism.
9-
#
10-
# note: This wouldn't be necessary if `nvcc` interacted with the POSIX jobserver.
117
#
128
# Boolean options:
139
# -h,--help Print this text.
@@ -18,16 +14,6 @@
1814
# -j,--parallel <num> Run <num> parallel compilation jobs.
1915
# --max-archs <num> Build at most <num> CUDA archs in parallel.
2016
# (default: 3)
21-
# --max-total-system-memory <num> An upper-bound on the amount of total system memory (in GiB) to use during
22-
# C++ and CUDA device compilations.
23-
# Smaller values yield fewer parallel C++ and CUDA device compilations.
24-
# (default: all available memory)
25-
# --max-device-obj-memory-usage <num> An upper-bound on the amount of memory each CUDA device object compilation
26-
# is expected to take. This is used to estimate the number of parallel device
27-
# object compilations that can be launched without hitting the system memory
28-
# limit.
29-
# Higher values yield fewer parallel CUDA device object compilations.
30-
# (default: 1)
3117

3218
# shellcheck disable=SC1091
3319
. rapids-generate-docstring;
@@ -41,33 +27,22 @@ get_num_archs_jobs_and_load() {
4127
# shellcheck disable=SC1091
4228
. devcontainer-utils-debug-output 'rapids_build_utils_debug' 'get-num-archs-jobs-and-load';
4329

44-
# The return value of nproc is (who knew!) constrained by the
45-
# values of OMP_NUM_THREADS and/or OMP_THREAD_LIMIT
46-
# Since we want the physical number of processors here, pass --all
47-
local -r n_cpus="$(nproc --all)";
30+
# nproc --all returns 2x the number of physical cores in Ubuntu24.04+,
31+
# so instead we cound the number of processors in /proc/cpuinfo
32+
local -r n_cpus="$(grep -cP 'processor\s+:' /proc/cpuinfo)";
4833

4934
if test ${#j[@]} -gt 0 && test -z "${j:-}"; then
5035
j="${n_cpus}";
5136
fi
5237

5338
parallel="${j:-${JOBS:-${PARALLEL_LEVEL:-1}}}";
5439
max_archs="${max_archs:-${MAX_DEVICE_OBJ_TO_COMPILE_IN_PARALLEL:-${arch:-}}}";
55-
max_device_obj_memory_usage="${max_device_obj_memory_usage:-${MAX_DEVICE_OBJ_MEMORY_USAGE:-1Gi}}";
56-
57-
local num_re="^[0-9]+$";
58-
59-
# Assume un-suffixed inputs means gibibytes
60-
if [[ "${max_device_obj_memory_usage}" =~ ${num_re} ]]; then
61-
max_device_obj_memory_usage="${max_device_obj_memory_usage}Gi";
62-
fi
63-
64-
max_device_obj_memory_usage="$(numfmt --from=auto "${max_device_obj_memory_usage}")";
6540

6641
local n_arch="${archs:-1}";
6742

68-
# currently: 70-real;75-real;80-real;86-real;90
69-
# see: https://github.com/rapidsai/rapids-cmake/blob/branch-24.04/rapids-cmake/cuda/set_architectures.cmake#L54
70-
local n_arch_rapids=5;
43+
# currently: 70-real;75-real;80-real;86-real;90-real;100-real;120
44+
# see: https://github.com/rapidsai/rapids-cmake/blob/branch-25.04/rapids-cmake/cuda/set_architectures.cmake#L59
45+
local n_arch_rapids=7;
7146

7247
if test -z "${archs:-}" \
7348
&& test -n "${INFER_NUM_DEVICE_ARCHITECTURES:-}"; then
@@ -102,31 +77,8 @@ get_num_archs_jobs_and_load() {
10277
n_arch=$((n_arch > max_archs ? max_archs : n_arch));
10378
fi
10479

105-
local mem_for_device_objs="$((n_arch * max_device_obj_memory_usage))";
106-
local mem_total="${max_total_system_memory:-${MAX_TOTAL_SYSTEM_MEMORY:-}}";
107-
108-
if test -z "${mem_total}"; then
109-
local -r free_mem="$(free --bytes | grep -E '^Mem:' | tr -s '[:space:]' | cut -d' ' -f7 || echo '0')";
110-
local -r freeswap="$(free --bytes | grep -E '^Swap:' | tr -s '[:space:]' | cut -d' ' -f4 || echo '0')";
111-
mem_total="$((free_mem + freeswap))";
112-
# Assume un-suffixed inputs means gibibytes
113-
elif [[ "${mem_total}" =~ ${num_re} ]]; then
114-
mem_total="${mem_total}Gi";
115-
fi
116-
mem_total="$(numfmt --from=auto "${mem_total}")";
117-
11880
local n_load=$((parallel > n_cpus ? n_cpus : parallel));
119-
# shellcheck disable=SC2155
120-
local n_jobs="$(
121-
echo "
122-
scale=0
123-
max_cpu=(${n_load} / ${n_arch} / 2 * 3)
124-
max_mem=(${mem_total} / ${mem_for_device_objs})
125-
if(max_cpu < max_mem) max_cpu else max_mem
126-
" | bc
127-
)"
128-
n_jobs=$((n_jobs < 1 ? 1 : n_jobs));
129-
n_jobs=$((n_arch > 1 ? n_jobs : n_load));
81+
local n_jobs="$((parallel < 1 ? 1 : parallel))";
13082

13183
echo "declare n_arch=${n_arch}";
13284
echo "declare n_jobs=${n_jobs}";

features/src/rapids-build-utils/opt/rapids-build-utils/bin/tmpl/cpp.configure.tmpl.sh

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ configure_${CPP_LIB}_cpp() {
5757

5858
time (
5959
export ${CPP_ENV} PATH="$PATH";
60+
SCCACHE_NO_DIST_COMPILE=1 \
6061
CUDAFLAGS="${CUDAFLAGS:+$CUDAFLAGS }-t=${n_arch}" \
6162
cmake "${cmake_args[@]}";
6263
{ set +x; } 2>/dev/null; echo -n "lib${CPP_LIB} configure time:";

features/src/utils/devcontainer-feature.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "devcontainer-utils",
33
"id": "utils",
4-
"version": "25.4.0",
4+
"version": "25.4.1",
55
"description": "A feature to install RAPIDS devcontainer utility scripts",
66
"containerEnv": {
77
"BASH_ENV": "/etc/bash.bash_env"

features/src/utils/install.sh

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ declare -a commands_and_sources=(
104104
"init-gitlab-cli gitlab/cli/init.sh"
105105
"clone-gitlab-repo gitlab/repo/clone.sh"
106106
"print-missing-gitlab-token-warning gitlab/print-missing-token-warning.sh"
107+
"configure-sccache-dist sccache-dist/configure.sh"
108+
"sccache-dist-status sccache-dist/status.sh"
107109
)
108110

109111
# Install alternatives

features/src/utils/opt/devcontainer/bin/github/cli/init.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ init_github_cli() {
3131
| tr -d ',' \
3232
)";
3333

34-
local needed_scopes="read:org";
34+
local needed_scopes="read:org read:enterprise";
3535

3636
needed_scopes="$( \
3737
comm -23 \

features/src/utils/opt/devcontainer/bin/post-attach-command.sh

+7
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ if test -z "${SKIP_DEVCONTAINER_UTILS_POST_ATTACH_COMMAND:-}"; then
55
. devcontainer-utils-init-git-interactive;
66
# shellcheck disable=SC1091
77
. devcontainer-utils-creds-s3-init;
8+
9+
if test -n "${ENABLE_SCCACHE_DIST+}"; then
10+
devcontainer-utils-configure-sccache-dist - <<< " \
11+
--auth-type 'token' \
12+
--auth-token '${SCCACHE_DIST_TOKEN:-$(gh auth token)}' \
13+
";
14+
fi
815
fi

0 commit comments

Comments
 (0)