Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix MODULE example in README #347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rhaps0dy
Copy link

The previous example in README failed with error:

ERROR: Analysis of target '//project_template/cpp:main' failed; build aborted: The module extension defined at /home/dev/.cache/bazel/_bazel_dev/0a671fc952be90f724e819c56b1dda7d/external/rules_cuda+/cuda/extensions.bzl:42:29 does not have a tag class named toolkit, but its use is attempted at /home/dev/llm/MODULE.bazel:4:13

we have to import toolkit instead of toolchain from cuda.

Also took the chance to bump rules_cuda.

The previous example in README failed with error:

```
ERROR: Analysis of target '//project_template/cpp:main' failed; build aborted: The module extension defined at /home/dev/.cache/bazel/_bazel_dev/0a671fc952be90f724e819c56b1dda7d/external/rules_cuda+/cuda/extensions.bzl:42:29 does not have a tag class named toolkit, but its use is attempted at /home/dev/llm/MODULE.bazel:4:13
```

we have to import toolkit instead of toolchain from cuda.
@cloudhan cloudhan mentioned this pull request Mar 10, 2025
17 tasks
@cloudhan
Copy link
Collaborator

cloudhan commented Mar 28, 2025

Sorry, my bad. Seems to be a mis-editting with bulk replace.

It seem does not have a tag class named toolkit using toolkit in your module, but toolchain is expected. So the example is in correct form.

@sebastian-sz
Copy link

@cloudhan Could you elaborate? The core example on the main branch does not seem to be correct:

# MODULE.bazel
bazel_dep(name = "rules_cuda", version = "0.2.1")
cuda = use_extension("@rules_cuda//cuda:extensions.bzl", "toolchain")
cuda.toolkit(
    name = "cuda",
    toolkit_path = "",
)
use_repo(cuda, "cuda")

Will fail:

root@a94b8f573df5:/workspace# bazel run //:mybin
ERROR: Analysis of target '//:mybin' failed; build aborted: The module extension defined at /root/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/rules_cuda+/cuda/extensions.bzl:42:29 does not have a tag class named toolkit, but its use is attempted at /workspace/MODULE.bazel:10:13
INFO: Elapsed time: 0.300s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

But replacing to:
cuda = use_extension("@rules_cuda//cuda:extensions.bzl", "toolkit")
will correctly compile the code.

@cloudhan
Copy link
Collaborator

You should use commit from main branch. The behavior is tested in CI and cannot be wrong.

local_path_override(
module_name = "rules_cuda",
path = "../../..",
)
cuda = use_extension("@rules_cuda//cuda:extensions.bzl", "toolchain")

So this is not a fix, it is a break.

@sebastian-sz
Copy link

sebastian-sz commented Apr 27, 2025

@cloudhan Thank you for the comment and the explanation. Using toolchain indeed does work on the current main branch.

bazel_dep(name = "rules_cuda", version = "0.2.3")
cuda = use_extension("@rules_cuda//cuda:extensions.bzl", "toolchain")
archive_override(
    module_name = "rules_cuda",
    integrity = "sha256-9PahCCOjx6Kqp2PFugoJEi09fXQBSsiOCxPbQbnMnFk=",
    url = "https://github.com/bazel-contrib/rules_cuda/archive/28177e2283a16b1e81c229e9bdc5610f1f3b07f7.tar.gz",
    strip_prefix = "rules_cuda-28177e2283a16b1e81c229e9bdc5610f1f3b07f7",
)

Do you think we could update the docs, for the MODULE.bazel install? Something like
"using toolchain is recommended onwards, for previous releases use toolkit"

I think it would help a lot with setting up the rules for the first timers. I'd be happy to submit such PR, let me how you feel about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants