diff --git a/.github/workflows/build-tests.yaml b/.github/workflows/build-tests.yaml index ac75c639..5703a417 100644 --- a/.github/workflows/build-tests.yaml +++ b/.github/workflows/build-tests.yaml @@ -16,7 +16,11 @@ jobs: cases: - { os: "ubuntu-20.04", cuda-version: "11.2.2", source: "nvidia" } - { os: "ubuntu-20.04", cuda-version: "11.6.2", source: "nvidia" } - - { os: "ubuntu-22.04", cuda-version: "11.5.1-1ubuntu1", source: "ubuntu" } + - { + os: "ubuntu-22.04", + cuda-version: "11.5.1-1ubuntu1", + source: "ubuntu", + } - { os: "windows-2019", cuda-version: "10.1.243", source: "nvidia" } - { os: "windows-2019", cuda-version: "11.6.2", source: "nvidia" } steps: diff --git a/docs/mkdocs/stylesheets/extra.css b/docs/mkdocs/stylesheets/extra.css index 58ac8189..ced394ba 100644 --- a/docs/mkdocs/stylesheets/extra.css +++ b/docs/mkdocs/stylesheets/extra.css @@ -1,5 +1,5 @@ .md-header { - background: #44a147 + background: #44a147; } .stardoc-pre { diff --git a/examples/if_cuda/README.md b/examples/if_cuda/README.md index b3ca8e45..ce35b973 100644 --- a/examples/if_cuda/README.md +++ b/examples/if_cuda/README.md @@ -3,7 +3,7 @@ This example demonstrates how to conditionally include CUDA targets in your build. By default, _rules_cuda_ rules are enabled. Disabling rules_cuda rules can be accomplished by passing the `@rules_cuda//cuda:enable` -flag at the command-line or via `.bazelrc`. +flag at the command-line or via `.bazelrc`. ## Building Example with rules_cuda @@ -14,16 +14,19 @@ bazel build //if_cuda:main ``` And run the binary: + ```bash ./bazel-bin/if_cuda/main ``` If a valid GPU device is running on your development machine, the application will exit successfully and print: + ``` cuda enabled ``` If running without a valid GPU device, the code, as written, will print a CUDA error and exit: + ``` CUDA_VISIBLE_DEVICES=-1 ./bazel-bin/if_cuda/main CUDA Error Code : 100 @@ -39,18 +42,20 @@ bazel build //if_cuda:main --@rules_cuda//cuda:enable` ``` And run the binary: + ```bash ./bazel-bin/if_cuda/main ``` The binary will output: + ``` cuda disabled ``` ### rules_cuda targets -Any attempt to build a rules_cuda-defined rule (e.g. `cuda_library` or `cuda_objects`) will _FAIL_ if rules_cuda is disabled, as the CUDA toolchain will not be registered for that invocation. +Any attempt to build a `rules_cuda`-defined rule (e.g. `cuda_library` or `cuda_objects`) will _FAIL_ if `rules_cuda` is disabled, as the CUDA toolchain will not be registered for that invocation. ``` bazel build //if_cuda:kernel --@rules_cuda//cuda:enable=false @@ -64,6 +69,7 @@ FAILED: Build did NOT complete successfully (0 packages loaded, 133 targets conf ## Developing for CUDA- and CUDA-free targets Note the `BUILD.bazel` file takes care to ensure that + - CUDA-related dependencies are excluded when CUDA is disabled - Preprocessor variables are set to enable compile-time differentiated codepaths between CUDA and non-CUDA builds @@ -78,4 +84,4 @@ select({ }) ``` -We use this same mechanism to include the `cuda_library` dependencies. \ No newline at end of file +We use this same mechanism to include the `cuda_library` dependencies.