Skip to content

Commit

Permalink
Apply some pre-commit fixes (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
garymm authored Jul 7, 2023
1 parent 33c3843 commit 090f403
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/mkdocs/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.md-header {
background: #44a147
background: #44a147;
}

.stardoc-pre {
Expand Down
12 changes: 9 additions & 3 deletions examples/if_cuda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -78,4 +84,4 @@ select({
})
```
We use this same mechanism to include the `cuda_library` dependencies.
We use this same mechanism to include the `cuda_library` dependencies.

0 comments on commit 090f403

Please sign in to comment.