GitXplorerGitXplorer
l

rules_cuda

public
20 stars
6 forks
3 issues

Commits

List of commits on branch main.
Unverified
7dcc4673fa487ad12fe3abe84d01edd9fe588e85

Add cufile.

lliuliu committed 2 months ago
Unverified
be346d4d12883469878edd693097f87723400c5b

Fix for CUDA 12.

lliuliu committed 2 years ago
Unverified
734c6864efc811e5e0bc203213c505dee56491ce

Fix regex matching doesn't work for CUDA 11.7 for cusolver (extra space).

lliuliu committed 2 years ago
Verified
9437a14aee0a84a1e3c76fee3482c502ad8f8f75

support cpp17 (#6)

rrnburn committed 3 years ago
Verified
503c98dab4491ef9eae9c30d3c88240d28d4e695

Support separate compilation of device code with nvcc (#4)

rrnburn committed 3 years ago
Unverified
d27ed9b54c3fa1639c20a72550258594f449cbff

Don't check version for cudart because 11.2 doesn't exist for CUDA 11.2.

lliuliu committed 4 years ago

README

The README file for this repository.

CUDA Rules for Bazel

This is an up-to-date set of Bazel rules to configure Linux builds with CUDA.

It is directly copied from Tensorflow with some updates. Hence, you need to configure TF_* environment variables to make it work.

An example of .bazelrc can be found in the root of this repository. For available configurations, you can find in cuda_configure.bzl

How to Use

To use rules provided in this repository, you can add following to your WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

http_archive(
  name = "bazel_skylib",
  sha256 = "1dde365491125a3db70731e25658dfdd3bc5dbdfd11b840b3e987ecf043c7ca0",
  urls = [
    "https://github.com/bazelbuild/bazel-skylib/releases/download/0.9.0/bazel_skylib-0.9.0.tar.gz",
  ],
)

git_repository(
  name = "build_bazel_rules_cuda",
  remote = "https://github.com/liuliu/rules_cuda.git",
  commit = "29f3ced1b7541ae629bbfabe0c07dbfe76f29f4d"
)

load("@build_bazel_rules_cuda//gpus:cuda_configure.bzl", "cuda_configure")

cuda_configure(name = "local_config_cuda")

cuda_library will be available after cuda_configure. An example BUILD file could look like this:

load("@local_config_cuda//cuda:build_defs.bzl", "cuda_library")

cuda_library(
    name = "vectorAdd",
    srcs = ["vectorAdd.cu"],
    hdrs = ["vectorAdd.h"],
    visibility = ["//visibility:public"],
    deps = [
        "@local_config_cuda//cuda:cuda",
    ],
)

cc_binary(
  name='main',
  srcs=['main.cc'],
  deps=[':vectorAdd'],
)

Note that you need to add @local_config_cuda//cuda:cuda explicitly for your target. This is helpful because rather than a sum of cuda dependency, you can add specifics if you only use a subset such as @local_config_cuda//cuda:cudnn. To see a list of available ones, you can query bazel query "deps(@local_config_cuda//cuda:cuda)"

Updates Differ from TensorFlow

  1. .cu is allowed, gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc.tpl modified to allow .cu suffix (it is already allowed from Bazel);

  2. Removed TF_DOWNLOAD_CLANG option.

Acknowledgement

This repository incorporated TensorFlow's CUDA rules, as well as some elements from Joe Toth's example repository: https://github.com/joetoth/bazel_cuda. TensorFlow rules updated from commit bde54d7aeaa23a47e1c5900464a8871d643e2e8e.