<commit_before># [CUDA](http://nvidia.com/cuda) rules for [Bazel](http://bazel.build)

The `@rules_cuda` repository primarily provides a `cuda_library()` macro which
allows compiling a C++ bazel target containing CUDA device code using nvcc or
clang.

The CUDA example program in this repository can be run with:

```
bazel run --cuda //examples:hello_cuda
```

For this, [rules_cc](https://github.com/bazelbuild/rules_cc)'s auto-configured
toolchain is patched to support a `cuda` feature which is then enabled for
`cuda_library()` targets.

A secondary `@local_cuda` repository contains bazel targets for the CUDA toolkit
installed on the execution machine.

## Requirements

Requires bazel 4.0 or later.

## Setup

Add the following snippet to your `WORKSPACE` file:

```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_cuda",
    urls = ["https://github.com/bazelbuild/rules_cuda/archive/????.zip"],
    sha256 = "????",
)
load("//cuda:dependencies.bzl", "rules_cuda_dependencies")
rules_cuda_dependencies()
load("@rules_cc//cc:repositories.bzl", "rules_cc_toolchains")
rules_cc_toolchains()
```

## Using `cuda_library`

Then, in the `BUILD` and/or `*.bzl` files in your own workspace, you can create
C++ targets containing CUDA device code with the `cuda_library` macro:
<commit_msg>rules_cuda: Updates the README instructions<commit_after># [CUDA](http://nvidia.com/cuda) rules for [Bazel](http://bazel.build)

The `@rules_cuda` repository primarily provides a `cuda_library()` macro which
allows compiling a C++ bazel target containing CUDA device code using nvcc or
clang.

For this, [rules_cc](https://github.com/bazelbuild/rules_cc)'s auto-configured
toolchain is patched to support a `cuda` feature which is then enabled for
`cuda_library()` targets.

A secondary `@local_cuda` repository contains bazel targets for the CUDA toolkit
installed on the execution machine.

## Requirements

Requires bazel 4.0 or later.

## Setup

Add the following snippet to your `WORKSPACE` file:

```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_cuda",
    sha256 = "f80438bee9906e9ecb1a8a4ae2365374ac1e8a283897281a2db2fb7fcf746333",
    strip_prefix = "runtime-b1c7cce21ba4661c17ac72421c6a0e2015e7bef3/third_party/rules_cuda",
    urls = ["https://github.com/tensorflow/runtime/archive/b1c7cce21ba4661c17ac72421c6a0e2015e7bef3.tar.gz"],
)
load("//cuda:dependencies.bzl", "rules_cuda_dependencies")
rules_cuda_dependencies()
load("@rules_cc//cc:repositories.bzl", "rules_cc_toolchains")
rules_cc_toolchains()
```

You can test your setup by running the example :

```
bazel run --@rules_cuda//cuda:enable_cuda @rules_cuda//examples:hello_cuda
```

## Using `cuda_library`

Then, in the `BUILD` and/or `*.bzl` files in your own workspace, you can create
C++ targets containing CUDA device code with the `cuda_library` macro:

{'fraction_non_alphanumeric': 0.12040816326530612, 'fraction_numerical': 0.0326530612244898, 'mean_word_length': 5.668934240362812, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7199543', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1015, 'n_words': 273}