Skip to content

Commit 1de8588

Browse files
authored
Merge branch 'main' into vk/typing
2 parents 33ac903 + 2df2c59 commit 1de8588

27 files changed

+994
-1167
lines changed

.github/workflows/pr.yaml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ jobs:
1919
- compute-matrix
2020
- build-conda
2121
- test-conda
22-
- test-conda-ctypes-binding
2322
- test-simulator
2423
- build-wheels
2524
- build-wheels-windows
2625
- test-wheels-windows
2726
- test-wheels
28-
- test-wheels-ctypes-binding
2927
- test-wheels-deps-wheels
3028
- test-thirdparty
3129
- build-docs
@@ -80,18 +78,6 @@ jobs:
8078
script: "ci/test_conda.sh"
8179
run_codecov: false
8280
matrix: ${{ needs.compute-matrix.outputs.TEST_MATRIX }}
83-
test-conda-ctypes-binding:
84-
needs:
85-
- build-conda
86-
- compute-matrix
87-
uses: ./.github/workflows/conda-python-tests.yaml
88-
with:
89-
build_type: pull-request
90-
script: "ci/test_conda_ctypes_binding.sh"
91-
run_codecov: false
92-
# This selects "ARCH=amd64 and CUDA >=12, with the latest supported Python for each CUDA major version".
93-
matrix: ${{ needs.compute-matrix.outputs.TEST_MATRIX }}
94-
matrix_filter: map(select(.ARCH == "amd64" and (.CUDA_VER | split(".") | .[0] | tonumber >= 12))) | group_by(.CUDA_VER|split(".")|map(tonumber)|.[0]) | map(max_by([(.PY_VER|split(".")|map(tonumber)), (.CUDA_VER|split(".")|map(tonumber))]))
9581
test-simulator:
9682
needs:
9783
- build-conda
@@ -124,17 +110,6 @@ jobs:
124110
build_type: pull-request
125111
script: "ci/test_wheel.sh false"
126112
matrix: ${{ needs.compute-matrix.outputs.TEST_MATRIX }}
127-
test-wheels-ctypes-binding:
128-
needs:
129-
- build-wheels
130-
- compute-matrix
131-
uses: ./.github/workflows/wheels-test.yaml
132-
with:
133-
build_type: pull-request
134-
script: "ci/test_wheel_ctypes_binding.sh"
135-
# This selects "ARCH=amd64 and CUDA >=12, with the latest supported Python for each CUDA major version".
136-
matrix: ${{ needs.compute-matrix.outputs.TEST_MATRIX }}
137-
matrix_filter: map(select(.ARCH == "amd64" and (.CUDA_VER | split(".") | .[0] | tonumber >= 12))) | group_by(.CUDA_VER|split(".")|map(tonumber)|.[0]) | map(max_by([(.PY_VER|split(".")|map(tonumber)), (.CUDA_VER|split(".")|map(tonumber))]))
138113
test-wheels-deps-wheels:
139114
needs:
140115
- build-wheels

ci/test_conda_ctypes_binding.sh

Lines changed: 0 additions & 70 deletions
This file was deleted.

ci/test_wheel_ctypes_binding.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

docs/source/reference/envvars.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,11 @@ target.
103103
Enable warnings if a kernel is launched with host memory which forces a copy to and
104104
from the device. This option is on by default (default value is 1).
105105

106-
.. envvar:: NUMBA_CUDA_USE_NVIDIA_BINDING
106+
.. note::
107107

108-
When set to 1, Numba will attempt to use the `NVIDIA CUDA Python binding
109-
<https://nvidia.github.io/cuda-python/>`_ to make calls to the driver API
110-
instead of using its own ctypes binding. This defaults to 1 (on). Set to
111-
0 to use the ctypes bindings.
108+
Numba-CUDA always uses the NVIDIA CUDA Python bindings. The legacy ctypes
109+
bindings and the ``NUMBA_CUDA_USE_NVIDIA_BINDING`` environment variable have
110+
been removed.
112111

113112
.. envvar:: NUMBA_CUDA_INCLUDE_PATH
114113

docs/source/user/bindings.rst

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,22 @@
55
CUDA Bindings
66
=============
77

8-
Numba supports two bindings to the CUDA Driver APIs: its own internal bindings
9-
based on ctypes, and the official `NVIDIA CUDA Python bindings
10-
<https://nvidia.github.io/cuda-python/>`_. Functionality is equivalent between
11-
the two bindings.
12-
13-
The internal bindings are used by default. If the NVIDIA bindings are installed,
14-
then they can be used by setting the environment variable
15-
``NUMBA_CUDA_USE_NVIDIA_BINDING`` to ``1`` prior to the import of Numba. Once
16-
Numba has been imported, the selected binding cannot be changed.
8+
Numba-CUDA uses the official `NVIDIA CUDA Python bindings
9+
<https://nvidia.github.io/cuda-python/>`_ for all CUDA Driver interactions.
10+
Numba-CUDA previously provided its own internal ctypes-based bindings; the
11+
public APIs exposing those bindings are kept for compatibility, but if you
12+
need to interact directly with the CUDA Driver or other CUDA libraries we
13+
recommend using the `cuda-python <https://nvidia.github.io/cuda-python/>`_
14+
package directly.
1715

1816

1917
Per-Thread Default Streams
2018
--------------------------
2119

2220
Responsibility for handling Per-Thread Default Streams (PTDS) is delegated to
23-
the NVIDIA bindings when they are in use. To use PTDS with the NVIDIA bindings,
24-
set the environment variable ``CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM`` to
25-
``1`` instead of Numba's environmnent variable
26-
:envvar:`NUMBA_CUDA_PER_THREAD_DEFAULT_STREAM`.
21+
the NVIDIA bindings. To use PTDS, set the environment variable
22+
``CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM`` to ``1`` instead of Numba's
23+
environment variable :envvar:`NUMBA_CUDA_PER_THREAD_DEFAULT_STREAM`.
2724

2825
.. seealso::
2926

@@ -35,13 +32,5 @@ set the environment variable ``CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM`` to
3532
Roadmap
3633
-------
3734

38-
In Numba 0.56, the NVIDIA Bindings will be used by default, if they are
39-
installed.
40-
41-
In future versions of Numba:
42-
43-
- The internal bindings will be deprecated.
44-
- The internal bindings will be removed.
45-
46-
At present, no specific release is planned for the deprecation or removal of
47-
the internal bindings.
35+
The ctypes-based internal bindings have been removed in favor of the NVIDIA
36+
bindings. Future work focuses on expanding usage of ``cuda.core`` APIs.

docs/source/user/installation.rst

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@ Configuration
6161
CUDA Bindings
6262
-------------
6363

64-
Numba supports interacting with the CUDA Driver API via either the `NVIDIA CUDA
65-
Python bindings <https://nvidia.github.io/cuda-python/>`_ or its own ctypes-based
66-
bindings. Functionality is equivalent between the two binding choices. The
67-
NVIDIA bindings are the default, and the ctypes bindings are now deprecated.
68-
69-
If you do not want to use the NVIDIA bindings, the (deprecated) ctypes bindings
70-
can be enabled by setting the environment variable
71-
:envvar:`NUMBA_CUDA_USE_NVIDIA_BINDING` to ``"0"``.
64+
Numba-CUDA uses the `NVIDIA CUDA Python bindings <https://nvidia.github.io/cuda-python/>`_
65+
for interacting with the CUDA Driver API. Numba-CUDA previously provided its own
66+
internal ctypes-based bindings; the public APIs exposing those bindings are kept
67+
for compatibility, but if you need to interact directly with the CUDA Driver or
68+
other CUDA libraries we recommend using the `cuda-python <https://nvidia.github.io/cuda-python/cuda-pathfinder/latest/generated/cuda.pathfinder.load_nvidia_dynamic_lib.html>`_
69+
package directly.
7270

7371

7472
.. _cudatoolkit-lookup:
@@ -79,22 +77,8 @@ CUDA Driver and Toolkit search paths
7977
Default behavior
8078
~~~~~~~~~~~~~~~~
8179

82-
When using the NVIDIA bindings, searches for the CUDA driver and toolkit
83-
libraries use its `built-in path-finding logic <https://github.com/NVIDIA/cuda-python/tree/main/cuda_bindings/cuda/bindings/_path_finder>`_.
84-
85-
Ctypes bindings (deprecated) behavior
86-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
87-
88-
When using the ctypes bindings, Numba searches for a CUDA toolkit installation
89-
in the following order:
90-
91-
1. Conda-installed CUDA Toolkit packages
92-
2. Pip-installed CUDA Toolkit packages
93-
3. The environment variable ``CUDA_HOME``, which points to the directory of the
94-
installed CUDA toolkit (i.e. ``/home/user/cuda-12``)
95-
4. System-wide installation at exactly ``/usr/local/cuda`` on Linux platforms.
96-
Versioned installation paths (i.e. ``/usr/local/cuda-12.0``) are intentionally
97-
ignored. Users can use ``CUDA_HOME`` to select specific versions.
80+
Searches for the CUDA driver and toolkit libraries use the NVIDIA bindings'
81+
`built-in path-finding logic <https://github.com/NVIDIA/cuda-python/tree/main/cuda_bindings/cuda/bindings/_path_finder>`_.
9882

9983
In addition to the CUDA toolkit libraries, which can be installed by conda into
10084
an environment or installed system-wide by the `CUDA SDK installer

numba_cuda/numba/cuda/__init__.py

Lines changed: 9 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,65 +8,15 @@
88
import sys
99

1010

11-
# Enable pynvjitlink based on the following precedence:
12-
# 1. Config setting "CUDA_ENABLE_PYNVJITLINK" (highest priority)
13-
# 2. Environment variable "NUMBA_CUDA_ENABLE_PYNVJITLINK"
14-
# 3. Auto-detection of pynvjitlink module (lowest priority)
15-
16-
pynvjitlink_auto_enabled = False
17-
18-
if getattr(config, "CUDA_ENABLE_PYNVJITLINK", None) is None:
19-
if (
20-
_pynvjitlink_enabled_in_env := _readenv(
21-
"NUMBA_CUDA_ENABLE_PYNVJITLINK", bool, None
22-
)
23-
) is not None:
24-
config.CUDA_ENABLE_PYNVJITLINK = _pynvjitlink_enabled_in_env
25-
else:
26-
pynvjitlink_auto_enabled = (
27-
importlib.util.find_spec("pynvjitlink") is not None
28-
)
29-
config.CUDA_ENABLE_PYNVJITLINK = pynvjitlink_auto_enabled
30-
31-
# Upstream numba sets CUDA_USE_NVIDIA_BINDING to 0 by default, so it always
32-
# exists. Override, but not if explicitly set to 0 in the envioronment.
33-
_nvidia_binding_enabled_in_env = _readenv(
34-
"NUMBA_CUDA_USE_NVIDIA_BINDING", bool, None
35-
)
36-
if _nvidia_binding_enabled_in_env is False:
37-
USE_NV_BINDING = False
38-
else:
39-
USE_NV_BINDING = True
40-
config.CUDA_USE_NVIDIA_BINDING = USE_NV_BINDING
41-
if config.CUDA_USE_NVIDIA_BINDING:
42-
if not (
43-
importlib.util.find_spec("cuda")
44-
and importlib.util.find_spec("cuda.bindings")
45-
):
46-
raise ImportError(
47-
"CUDA bindings not found. Please pip install the "
48-
"cuda-bindings package. Alternatively, install "
49-
"numba-cuda[cuXY], where XY is the required CUDA "
50-
"version, to install the binding automatically. "
51-
"If no CUDA bindings are desired, set the env var "
52-
"NUMBA_CUDA_USE_NVIDIA_BINDING=0 to enable ctypes "
53-
"bindings."
54-
)
55-
56-
if config.CUDA_ENABLE_PYNVJITLINK:
57-
if USE_NV_BINDING and not pynvjitlink_auto_enabled:
58-
warnings.warn(
59-
"Explicitly enabling pynvjitlink is no longer necessary. "
60-
"NVIDIA bindings are enabled. cuda.core will be used "
61-
"in place of pynvjitlink."
62-
)
63-
elif pynvjitlink_auto_enabled:
64-
# Ignore the fact that pynvjitlink is enabled, because that was an
65-
# automatic decision based on discovering pynvjitlink was present; the
66-
# user didn't ask for it
67-
pass
68-
else:
69-
raise RuntimeError("nvJitLink requires the NVIDIA CUDA bindings. ")
11+
# Require NVIDIA CUDA bindings at import time
12+
if not (
13+
importlib.util.find_spec("cuda")
14+
and importlib.util.find_spec("cuda.bindings")
15+
):
16+
raise ImportError(
17+
"NVIDIA CUDA Python bindings not found. Install the 'cuda' package "
18+
"(e.g. pip install nvidia-cuda-python or numba-cuda[cuXY])."
19+
)
7020

7121
if config.ENABLE_CUDASIM:
7222
from .simulator_init import *

numba_cuda/numba/cuda/api.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import contextlib
99
import os
1010

11-
from numba.cuda.cudadrv import drvapi
1211
import numpy as np
1312

1413
from .cudadrv import devicearray, devices, driver
@@ -48,10 +47,7 @@ def from_cuda_array_interface(desc, owner=None, sync=True):
4847
)
4948
size = driver.memory_size_from_info(shape, strides, dtype.itemsize)
5049

51-
if config.CUDA_USE_NVIDIA_BINDING:
52-
cudevptr_class = driver.binding.CUdeviceptr
53-
else:
54-
cudevptr_class = drvapi.cu_device_ptr
50+
cudevptr_class = driver.binding.CUdeviceptr
5551
devptr = cudevptr_class(desc["data"][0])
5652
data = driver.MemoryPointer(
5753
current_context(), devptr, size=size, owner=owner

numba_cuda/numba/cuda/codegen.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ def run_nvdisasm(cubin, flags):
2626
try:
2727
fd, fname = tempfile.mkstemp()
2828
with open(fname, "wb") as f:
29-
if config.CUDA_USE_NVIDIA_BINDING:
30-
f.write(cubin.code)
31-
else:
32-
f.write(cubin)
29+
f.write(cubin.code)
3330

3431
try:
3532
cp = subprocess.run(

0 commit comments

Comments
 (0)