Skip to content

Commit 7a9451d

Browse files
authored
Add RMM devcontainers (rapidsai#1328)
This PR adds some [devcontainers](https://containers.dev/) to help simplify building the RMM C++ and Python libraries. It also adds an optional job to the `pr.yaml` to [build the RMM libs in each devcontainer](https://github.com/trxcllnt/rmm/blob/fea/devcontainers/.github/workflows/pr.yaml#L79-L85), so the build caches are populated for devs by CI. A devcontainer can be launched by clicking the "Reopen in Container" button that VSCode shows when opening the repo (or by using the "Rebuild and Reopen in Container" command from the command palette): ![image](https://user-images.githubusercontent.com/178183/221771999-97ab29d5-e718-4e5f-b32f-2cdd51bba25c.png) Clicking this button will cause VSCode to prompt the user to select one of these devcontainer variants: ![image](https://github.com/rapidsai/rmm/assets/178183/68d4b264-4fc2-4008-92b6-cb4bdd19b29f) On startup, the devcontainer creates or updates the conda/pip environment using `rmm/dependencies.yaml`. The envs/package caches are cached on the host via volume mounts, which are described in more detail in [`.devcontainer/README.md`](https://github.com/trxcllnt/rmm/blob/fea/devcontainers/.devcontainer/README.md). The container includes convenience functions to clean, configure, and build the various RMM components: ```shell $ clean-rmm-cpp # only cleans the C++ build dir $ clean-rmm-python # only cleans the Python build dir $ clean-rmm # cleans both C++ and Python build dirs $ configure-rmm-cpp # only configures rmm C++ lib $ build-rmm-cpp # only builds rmm C++ lib $ build-rmm-python # only builds rmm Python lib $ build-rmm # builds both C++ and Python libs ``` * The C++ build script is a small wrapper around `cmake -S ~/rmm -B ~/rmm/build` and `cmake --build ~/rmm/build` * The Python build script is a small wrapper around `pip install --editable ~/rmm` Unlike `build.sh`, these convenience scripts *don't* install the libraries after building them. Instead, they automatically inject the correct arguments to build the C++ libraries from source and use their build dirs as package roots: ```shell $ cmake -S ~/rmm -B ~/rmm/build $ CMAKE_ARGS="-Drmm_ROOT=~/rmm/build" \ # <-- this argument is automatic pip install -e ~/rmm ``` Authors: - Paul Taylor (https://github.com/trxcllnt) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) - AJ Schmidt (https://github.com/ajschmidt8) URL: rapidsai#1328
1 parent c8acf76 commit 7a9451d

File tree

14 files changed

+335
-3
lines changed

14 files changed

+335
-3
lines changed

.clangd

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# https://clangd.llvm.org/config
2+
3+
# Apply a config conditionally to all C files
4+
If:
5+
PathMatch: .*\.(c|h)$
6+
7+
---
8+
9+
# Apply a config conditionally to all C++ files
10+
If:
11+
PathMatch: .*\.(c|h)pp
12+
13+
---
14+
15+
# Apply a config conditionally to all CUDA files
16+
If:
17+
PathMatch: .*\.cuh?
18+
CompileFlags:
19+
Add:
20+
- "-x"
21+
- "cuda"
22+
# No error on unknown CUDA versions
23+
- "-Wno-unknown-cuda-version"
24+
# Allow variadic CUDA functions
25+
- "-Xclang=-fcuda-allow-variadic-functions"
26+
Diagnostics:
27+
Suppress:
28+
- "variadic_device_fn"
29+
- "attributes_not_allowed"
30+
31+
---
32+
33+
# Tweak the clangd parse settings for all files
34+
CompileFlags:
35+
Add:
36+
# report all errors
37+
- "-ferror-limit=0"
38+
- "-fmacro-backtrace-limit=0"
39+
- "-ftemplate-backtrace-limit=0"
40+
# Skip the CUDA version check
41+
- "--no-cuda-version-check"
42+
Remove:
43+
# remove gcc's -fcoroutines
44+
- -fcoroutines
45+
# remove nvc++ flags unknown to clang
46+
- "-gpu=*"
47+
- "-stdpar*"
48+
# remove nvcc flags unknown to clang
49+
- "-arch*"
50+
- "-gencode*"
51+
- "--generate-code*"
52+
- "-ccbin*"
53+
- "-t=*"
54+
- "--threads*"
55+
- "-Xptxas*"
56+
- "-Xcudafe*"
57+
- "-Xfatbin*"
58+
- "-Xcompiler*"
59+
- "--diag-suppress*"
60+
- "--diag_suppress*"
61+
- "--compiler-options*"
62+
- "--expt-extended-lambda"
63+
- "--expt-relaxed-constexpr"
64+
- "-forward-unknown-to-host-compiler"
65+
- "-Werror=cross-execution-space-call"

.devcontainer/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# syntax=docker/dockerfile:1.5
2+
3+
ARG BASE
4+
ARG PYTHON_PACKAGE_MANAGER=conda
5+
6+
FROM ${BASE} as pip-base
7+
8+
ENV DEFAULT_VIRTUAL_ENV=rapids
9+
10+
FROM ${BASE} as conda-base
11+
12+
ENV DEFAULT_CONDA_ENV=rapids
13+
14+
FROM ${PYTHON_PACKAGE_MANAGER}-base
15+
16+
ARG CUDA
17+
ENV CUDAARCHS="RAPIDS"
18+
ENV CUDA_VERSION="${CUDA_VERSION:-${CUDA}}"
19+
20+
ARG PYTHON_PACKAGE_MANAGER
21+
ENV PYTHON_PACKAGE_MANAGER="${PYTHON_PACKAGE_MANAGER}"
22+
23+
ENV PYTHONSAFEPATH="1"
24+
ENV PYTHONUNBUFFERED="1"
25+
ENV PYTHONDONTWRITEBYTECODE="1"
26+
27+
ENV SCCACHE_REGION="us-east-2"
28+
ENV SCCACHE_BUCKET="rapids-sccache-devs"
29+
ENV VAULT_HOST="https://vault.ops.k8s.rapids.ai"
30+
ENV HISTFILE="/home/coder/.cache/._bash_history"

.devcontainer/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# RMM Development Containers
2+
3+
This directory contains [devcontainer configurations](https://containers.dev/implementors/json_reference/) for using VSCode to [develop in a container](https://code.visualstudio.com/docs/devcontainers/containers) via the `Remote Containers` [extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) or [GitHub Codespaces](https://github.com/codespaces).
4+
5+
This container is a turnkey development environment for building and testing the RMM C++ and Python libraries.
6+
7+
## Table of Contents
8+
9+
* [Prerequisites](#prerequisites)
10+
* [Host bind mounts](#host-bind-mounts)
11+
* [Launch a Dev Container](#launch-a-dev-container)
12+
13+
## Prerequisites
14+
15+
* [VSCode](https://code.visualstudio.com/download)
16+
* [VSCode Remote Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
17+
18+
## Host bind mounts
19+
20+
By default, the following directories are bind-mounted into the devcontainer:
21+
22+
* `${repo}:/home/coder/rmm`
23+
* `${repo}/../.aws:/home/coder/.aws`
24+
* `${repo}/../.local:/home/coder/.local`
25+
* `${repo}/../.cache:/home/coder/.cache`
26+
* `${repo}/../.conda:/home/coder/.conda`
27+
* `${repo}/../.config:/home/coder/.config`
28+
29+
This ensures caches, configurations, dependencies, and your commits are persisted on the host across container runs.
30+
31+
## Launch a Dev Container
32+
33+
To launch a devcontainer from VSCode, open the RMM repo and select the "Reopen in Container" button in the bottom right:<br/><img src="https://user-images.githubusercontent.com/178183/221771999-97ab29d5-e718-4e5f-b32f-2cdd51bba25c.png"/>
34+
35+
Alternatively, open the VSCode command palette (typically `cmd/ctrl + shift + P`) and run the "Rebuild and Reopen in Container" command.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"build": {
3+
"context": "${localWorkspaceFolder}/.devcontainer",
4+
"dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile",
5+
"args": {
6+
"CUDA": "11.8",
7+
"PYTHON_PACKAGE_MANAGER": "conda",
8+
"BASE": "rapidsai/devcontainers:23.10-cpp-llvm16-cuda11.8-mambaforge-ubuntu22.04"
9+
}
10+
},
11+
"hostRequirements": {"gpu": "optional"},
12+
"features": {
13+
"ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.10": {}
14+
},
15+
"overrideFeatureInstallOrder": [
16+
"ghcr.io/rapidsai/devcontainers/features/rapids-build-utils"
17+
],
18+
"initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda11.8-envs}"],
19+
"postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"],
20+
"workspaceFolder": "/home/coder",
21+
"workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent",
22+
"mounts": [
23+
"source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent",
24+
"source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent",
25+
"source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent",
26+
"source=${localWorkspaceFolder}/../.conda/pkgs,target=/home/coder/.conda/pkgs,type=bind,consistency=consistent",
27+
"source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda11.8-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent"
28+
],
29+
"customizations": {
30+
"vscode": {
31+
"extensions": [
32+
"ms-python.flake8",
33+
"nvidia.nsight-vscode-edition"
34+
]
35+
}
36+
}
37+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"build": {
3+
"context": "${localWorkspaceFolder}/.devcontainer",
4+
"dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile",
5+
"args": {
6+
"CUDA": "11.8",
7+
"PYTHON_PACKAGE_MANAGER": "pip",
8+
"BASE": "rapidsai/devcontainers:23.10-cpp-llvm16-cuda11.8-ubuntu22.04"
9+
}
10+
},
11+
"hostRequirements": {"gpu": "optional"},
12+
"features": {
13+
"ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.10": {}
14+
},
15+
"overrideFeatureInstallOrder": [
16+
"ghcr.io/rapidsai/devcontainers/features/rapids-build-utils"
17+
],
18+
"initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda11.8-venvs}"],
19+
"postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"],
20+
"workspaceFolder": "/home/coder",
21+
"workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent",
22+
"mounts": [
23+
"source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent",
24+
"source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent",
25+
"source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent",
26+
"source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda11.8-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent"
27+
],
28+
"customizations": {
29+
"vscode": {
30+
"extensions": [
31+
"ms-python.flake8",
32+
"nvidia.nsight-vscode-edition"
33+
]
34+
}
35+
}
36+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"build": {
3+
"context": "${localWorkspaceFolder}/.devcontainer",
4+
"dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile",
5+
"args": {
6+
"CUDA": "12.0",
7+
"PYTHON_PACKAGE_MANAGER": "conda",
8+
"BASE": "rapidsai/devcontainers:23.10-cpp-mambaforge-ubuntu22.04"
9+
}
10+
},
11+
"hostRequirements": {"gpu": "optional"},
12+
"features": {
13+
"ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.10": {}
14+
},
15+
"overrideFeatureInstallOrder": [
16+
"ghcr.io/rapidsai/devcontainers/features/rapids-build-utils"
17+
],
18+
"initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.0-envs}"],
19+
"postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"],
20+
"workspaceFolder": "/home/coder",
21+
"workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent",
22+
"mounts": [
23+
"source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent",
24+
"source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent",
25+
"source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent",
26+
"source=${localWorkspaceFolder}/../.conda/pkgs,target=/home/coder/.conda/pkgs,type=bind,consistency=consistent",
27+
"source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.0-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent"
28+
],
29+
"customizations": {
30+
"vscode": {
31+
"extensions": [
32+
"ms-python.flake8",
33+
"nvidia.nsight-vscode-edition"
34+
]
35+
}
36+
}
37+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"build": {
3+
"context": "${localWorkspaceFolder}/.devcontainer",
4+
"dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile",
5+
"args": {
6+
"CUDA": "12.0",
7+
"PYTHON_PACKAGE_MANAGER": "pip",
8+
"BASE": "rapidsai/devcontainers:23.10-cpp-llvm16-cuda12.0-ubuntu22.04"
9+
}
10+
},
11+
"hostRequirements": {"gpu": "optional"},
12+
"features": {
13+
"ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.10": {}
14+
},
15+
"overrideFeatureInstallOrder": [
16+
"ghcr.io/rapidsai/devcontainers/features/rapids-build-utils"
17+
],
18+
"initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.0-venvs}"],
19+
"postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"],
20+
"workspaceFolder": "/home/coder",
21+
"workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent",
22+
"mounts": [
23+
"source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent",
24+
"source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent",
25+
"source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent",
26+
"source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.0-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent"
27+
],
28+
"customizations": {
29+
"vscode": {
30+
"extensions": [
31+
"ms-python.flake8",
32+
"nvidia.nsight-vscode-edition"
33+
]
34+
}
35+
}
36+
}

.github/workflows/pr.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
- docs-build
2121
- wheel-build
2222
- wheel-tests
23+
- devcontainer
2324
secrets: inherit
2425
uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.10
2526
checks:
@@ -75,3 +76,11 @@ jobs:
7576
with:
7677
build_type: pull-request
7778
script: ci/test_wheel.sh
79+
devcontainer:
80+
secrets: inherit
81+
uses: rapidsai/shared-action-workflows/.github/workflows/build-in-devcontainer.yaml@branch-23.10
82+
with:
83+
build_command: |
84+
sccache -z;
85+
build-all -DBUILD_BENCHMARKS=ON --verbose;
86+
sccache -s;

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,7 @@ rmm_log.txt
154154

155155
# cibuildwheel
156156
/wheelhouse
157+
158+
# clang tooling
159+
compile_commands.json
160+
.clangd/

ci/release/update-version.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ NEXT_MAJOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[1]}')
2222
NEXT_MINOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[2]}')
2323
NEXT_SHORT_TAG=${NEXT_MAJOR}.${NEXT_MINOR}
2424

25+
# Need to distutils-normalize the original version
26+
NEXT_SHORT_TAG_PEP440=$(python -c "from setuptools.extern import packaging; print(packaging.version.Version('${NEXT_SHORT_TAG}'))")
27+
2528
echo "Preparing release $CURRENT_TAG => $NEXT_FULL_TAG"
2629

2730
# Inplace sed replace; workaround for Linux and Mac
@@ -55,3 +58,9 @@ for FILE in .github/workflows/*.yaml; do
5558
sed_runner "/shared-action-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}"
5659
done
5760
sed_runner "s/RAPIDS_VERSION_NUMBER=\".*/RAPIDS_VERSION_NUMBER=\"${NEXT_SHORT_TAG}\"/g" ci/build_docs.sh
61+
62+
# .devcontainer files
63+
find .devcontainer/ -type f -name devcontainer.json -print0 | while IFS= read -r -d '' filename; do
64+
sed_runner "s@rapidsai/devcontainers:[0-9.]*@rapidsai/devcontainers:${NEXT_SHORT_TAG}@g" "${filename}"
65+
sed_runner "s@rapidsai/devcontainers/features/rapids-build-utils:[0-9.]*@rapidsai/devcontainers/features/rapids-build-utils:${NEXT_SHORT_TAG_PEP440}@" "${filename}"
66+
done

0 commit comments

Comments
 (0)