You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The CUDA runtime is linked statically (`CUDA_RUNTIME_LIBRARY Static`), so the
66
+
resulting wheels do not depend on `libcudart` and remain importable on machines
67
+
without a GPU (where `add` transparently falls back to the CPU). GitHub-hosted
68
+
runners have no GPU, so the wheels are compiled and imported, but the kernel
69
+
itself only runs on a machine with a CUDA device.
70
+
38
71
## Files
39
72
40
73
This example has several files that are a good idea, but aren't strictly
41
74
necessary. The necessary files are:
42
75
43
76
* `pyproject.toml`: The Python project file
44
-
*`CMakeLists.txt`: The CMake configuration file
45
-
*`src/main.cpp`: The source file for the C++ build
46
-
*`src/scikit_build_example/__init__.py`: The Python portion of the module. The root of the module needs to be `<package_name>`, `src/<package_name>`, or `python/<package_name>` to be auto-discovered.
77
+
* `CMakeLists.txt`: The CMake configuration file, which conditionally enables CUDA
78
+
* `src/main.cpp`: The pybind11 bindings
79
+
* `src/add.cu`: The CUDA kernel implementation (built when CUDA is available)
80
+
* `src/add_cpu.cpp`: The CPU fallback (built when CUDA is not available)
81
+
* `src/add.h`: The shared declarations
82
+
* `src/cuda_example/__init__.py`: The Python portion of the module. The root of the module needs to be `<package_name>`, `src/<package_name>`, or `python/<package_name>` to be auto-discovered.
47
83
48
84
These files are also expected and highly recommended:
49
85
@@ -71,9 +107,10 @@ choice.
71
107
72
108
### CI Examples
73
109
74
-
There are examples for CI in `.github/workflows`. A simple way to produces
110
+
There are examples for CI in `.github/workflows`. A simple way to produce
75
111
binary "wheels" for all platforms is illustrated in the "wheels.yml" file,
76
-
using [cibuildwheel][].
112
+
using [cibuildwheel][]. The "cibw-cuda.yaml" file shows how to build
113
+
CUDA-enabled wheels on Linux.
77
114
78
115
## License
79
116
@@ -82,11 +119,12 @@ file. By using, distributing, or contributing to this project, you agree to the
0 commit comments