Skip to content
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

Custom cuda version usage #195

Closed
the-code-samurai-97 opened this issue Nov 19, 2023 · 4 comments
Closed

Custom cuda version usage #195

the-code-samurai-97 opened this issue Nov 19, 2023 · 4 comments

Comments

@the-code-samurai-97
Copy link

My Laptop uses cuda 11.7 and i want to use Cuda 12 , Is there a way to use cuda 12.x without local installing can i download tar.gz using bazel

@cloudhan
Copy link
Collaborator

Sorry, I don't quite get you language. I am guessing that you want to extract the cuda toolkit to a non-standard path (that is, without instlalling), Then you can use call rules_cuda_dependencies(toolkit_path="<your_custom_cuda_path>") in your WORKSPACE file or you can use --repo_env=CUDA_PATH=<your_custom_cuda_path>

See https://github.com/bazel-contrib/rules_cuda/blob/5633f0c0f7/cuda/private/repositories.bzl#L31-L35

@sibi-venti
Copy link

can i download the cuda and compile using bazel?

@cloudhan
Copy link
Collaborator

@sibi-venti

Previous method change where the cuda_path point to, then in

def detect_cuda_toolkit(repository_ctx):
"""Detect CUDA Toolkit.
The path to CUDA Toolkit is determined as:
- the value of `toolkit_path` passed to local_cuda as an attribute
- taken from `CUDA_PATH` environment variable or
- determined through 'which ptxas' or
- defaults to '/usr/local/cuda'
Args:
repository_ctx: repository_ctx
Returns:
A struct contains the information of CUDA Toolkit.
"""
cuda_path = repository_ctx.attr.toolkit_path
if cuda_path == "":
cuda_path = repository_ctx.os.environ.get("CUDA_PATH", None)
if cuda_path == None:
ptxas_path = repository_ctx.which("ptxas")
if ptxas_path:
# ${CUDA_PATH}/bin/ptxas
# Some distributions instead put CUDA binaries in a seperate path
# Manually check and redirect there when necessary
alternative = repository_ctx.path("/usr/lib/nvidia-cuda-toolkit/bin/nvcc")
if str(ptxas_path) == "/usr/bin/ptxas" and alternative.exists:
ptxas_path = alternative
cuda_path = str(ptxas_path.dirname.dirname)
if cuda_path == None and _is_linux(repository_ctx):
cuda_path = "/usr/local/cuda"
if cuda_path != None and not repository_ctx.path(cuda_path).exists:
cuda_path = None
bin_ext = ".exe" if _is_windows(repository_ctx) else ""
nvlink = "@rules_cuda//cuda/dummy:nvlink"
link_stub = "@rules_cuda//cuda/dummy:link.stub"
bin2c = "@rules_cuda//cuda/dummy:bin2c"
fatbinary = "@rules_cuda//cuda/dummy:fatbinary"
if cuda_path != None:
if repository_ctx.path(cuda_path + "/bin/nvlink" + bin_ext).exists:
nvlink = str(Label("@local_cuda//:cuda/bin/nvlink{}".format(bin_ext)))
if repository_ctx.path(cuda_path + "/bin/crt/link.stub").exists:
link_stub = str(Label("@local_cuda//:cuda/bin/crt/link.stub"))
if repository_ctx.path(cuda_path + "/bin/bin2c" + bin_ext).exists:
bin2c = str(Label("@local_cuda//:cuda/bin/bin2c{}".format(bin_ext)))
if repository_ctx.path(cuda_path + "/bin/fatbinary" + bin_ext).exists:
fatbinary = str(Label("@local_cuda//:cuda/bin/fatbinary{}".format(bin_ext)))
nvcc_version_major = -1
nvcc_version_minor = -1
if cuda_path != None:
nvcc_version_major, nvcc_version_minor = _get_nvcc_version(repository_ctx, cuda_path)

_get_nvcc_version runs the nvcc to extract the version for your.

So the answer is yes and no. bazel does not compile, instead, it drives the compilation.

@cloudhan
Copy link
Collaborator

So by override the default cuda toolkit search path, and still relying the detecting machenism, you don't need do anything. Otherwise it should be treated as a bug.

@the-code-samurai-97 the-code-samurai-97 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2023
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

No branches or pull requests

3 participants