-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
How to use cublas in a non-root bazel module? #238
Comments
With current impl, it is not possible. But it is very reasonable to let upstream projects expose targets that depend on rules_cuda, say, kernels wrapped in a c library with c public interfaces. Current project and downstream projects should be able to use it without pain. I'll see how we should improve the situation. |
Thanks for looking into this! Really appreciated. Do you mean that my upstream module A uses This doesn't seem to work -- it looks as long as I use I tried to remove everything that's referring to bazel_dep(
name = "rules_cuda",
version = "0.2.1",
) and I use load("@rules_cuda//cuda:defs.bzl", "cuda_library")
cuda_library(
name = "kernel",
srcs = ["kernel.cu"],
hdrs = ["kernel.h"],
) then A cannot compile by bazel.
This is referring to Line 10 in 8f2f2e6
Adding |
Oh, didn't see a fix is in the making! Looking forward to it 👍 |
I think its possible to just do:
in B's |
yes, this would work to compile |
You would leave your |
Thanks for your response! I kind of get it work for my purpose, by using different My setup:
Now this is the complete file content of """repo A."""
module(
name = "repo_a",
version = "1.0.0",
)
bazel_dep(
name = "bazel_skylib",
version = "1.5.0",
)
bazel_dep(
name = "rules_cc",
version = "0.0.9",
)
bazel_dep(
name = "rules_cuda",
version = "1.0.0",
)
cuda = use_extension("@rules_cuda//cuda:extensions.bzl", "toolchain")
use_repo(cuda, "local_cuda") This is the complete content of """repo_b"""
module(
name = "repo_b",
version = "1.0.0",
)
bazel_dep(
name = "bazel_skylib",
version = "1.5.0",
)
bazel_dep(
name = "rules_cc",
version = "0.0.9",
)
bazel_dep(
name = "repo_a",
version = "1.0.0",
)
bazel_dep(
name = "rules_cuda",
version = "1.0.0",
)
cuda = use_extension("@rules_cuda//cuda:extensions.bzl", "toolchain")
cuda.local_toolchain(
name = "local_cuda",
toolkit_path = "",
)
use_repo(cuda, "local_cuda") This works, and
Now
To workaround this, I need to use a slightly different """repo A."""
module(
name = "repo_a",
version = "1.0.0",
)
bazel_dep(
name = "bazel_skylib",
version = "1.5.0",
)
bazel_dep(
name = "rules_cc",
version = "0.0.9",
)
bazel_dep(
name = "rules_cuda",
version = "1.0.0",
)
cuda = use_extension("@rules_cuda//cuda:extensions.bzl", "toolchain")
cuda.local_toolchain(
name = "local_cuda",
toolkit_path = "",
)
use_repo(cuda, "local_cuda") Note that I add So far I got both Not sure if this is the canonical way of setting up local dependencies, and it feels like a hack. It will be nice if we can remove the limitation of toolchains declaration, and that avoids all these tricky situations and the MODULE.bazel files won't have to diverge between the one in the repo vs. the one in the bazel registry. (PS: I'm using the head version of |
I'm using
rules_cuda
in a bazel MODULEA
, and some of mycuda_library
needs to link with-lcubas
and-lcublasLt
.Naturally, I'm defining
local_cuda
like examples/cublas/BUILD.bazel. . In myMODULE.bazel
of moduleA
:And in my
BUILD.bazel
, I have thecuda_library
target:This works fine when I build my module
A
. However, when I have another bazel moduleB
that depends on moduleA
, I cannot build moduleB
, because thelocal_cuda
can only be declared in a root module. I got this error:This is from this line:
rules_cuda/cuda/extensions.bzl
Line 15 in 8f2f2e6
Is it possible to use
rules_cuda
in a bazel module that other modules can depend? I don't really need to customize my cuda path, as the default path works fine with me. Is there a way to avoid the above error?The text was updated successfully, but these errors were encountered: