Skip to content

Commit 5f2aec6

Browse files
pentschevjameslamb
andauthored
Replace numba-cuda runtime dependency with cuda-core (#589)
* Replace numba-cuda runtime dependency with cuda-core * Fix numba-cuda selection of CUDA-versioned packages --------- Co-authored-by: James Lamb <jaylamb20@gmail.com>
1 parent a0f47f8 commit 5f2aec6

15 files changed

Lines changed: 125 additions & 79 deletions

File tree

conda/environments/all_cuda-129_arch-aarch64.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
- c-compiler
1111
- cloudpickle
1212
- cmake>=3.26.4,!=3.30.0
13+
- cuda-core>=0.3.2
1314
- cuda-cudart-dev
1415
- cuda-nvcc
1516
- cuda-version=12.9

conda/environments/all_cuda-129_arch-x86_64.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
- c-compiler
1111
- cloudpickle
1212
- cmake>=3.26.4,!=3.30.0
13+
- cuda-core>=0.3.2
1314
- cuda-cudart-dev
1415
- cuda-nvcc
1516
- cuda-version=12.9

conda/environments/all_cuda-131_arch-aarch64.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
- c-compiler
1111
- cloudpickle
1212
- cmake>=3.26.4,!=3.30.0
13+
- cuda-core>=0.3.2
1314
- cuda-cudart-dev
1415
- cuda-nvcc
1516
- cuda-version=13.1

conda/environments/all_cuda-131_arch-x86_64.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
- c-compiler
1111
- cloudpickle
1212
- cmake>=3.26.4,!=3.30.0
13+
- cuda-core>=0.3.2
1314
- cuda-cudart-dev
1415
- cuda-nvcc
1516
- cuda-version=13.1

conda/recipes/ucxx/recipe.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,7 @@ outputs:
290290
- ${{ pin_subpackage("libucxx", exact=True) }}
291291
- cuda-cudart-dev
292292
run:
293-
- numba >=0.60.0,<0.62.0
294-
- numba-cuda >=0.22.1
293+
- cuda-core >=0.3.2
295294
- numpy >=1.23,<3.0
296295
# 'nvidia-ml-py' provides the 'pynvml' module
297296
- nvidia-ml-py>=12
@@ -431,8 +430,7 @@ outputs:
431430
- setuptools>=77.0.0
432431
- wheel
433432
run:
434-
- numba >=0.60.0,<0.62.0
435-
- numba-cuda >=0.22.1
433+
- cuda-core >=0.3.2
436434
- python
437435
- pyyaml >=6
438436
- rapids-dask-dependency ${{ rapids_version }}

dependencies.yaml

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -297,73 +297,74 @@ dependencies:
297297
- &numpy numpy>=1.23,<3.0
298298
# 'nvidia-ml-py' provides the 'pynvml' module
299299
- nvidia-ml-py>=12
300+
- cuda-core>=0.3.2
301+
run_python_distributed_ucxx:
302+
common:
303+
- output_types: [conda, requirements, pyproject]
304+
packages:
305+
- rapids-dask-dependency==26.4.*,>=0.0.0a0
306+
- pyyaml>=6
307+
- cuda-core>=0.3.2
308+
test_cpp:
309+
common:
310+
- output_types: conda
311+
packages:
312+
- *cmake_ver
313+
test_python_ucxx:
314+
common:
315+
- output_types: [conda, requirements, pyproject]
316+
packages:
317+
- cloudpickle
318+
- pytest<9.0.0
319+
- pytest-asyncio>=1.0.0
320+
- pytest-rerunfailures!=16.0.0 # See https://github.com/pytest-dev/pytest-rerunfailures/issues/302
321+
- rapids-dask-dependency==26.4.*,>=0.0.0a0
300322
- output_types: [conda]
301323
packages:
302-
- &numba_cuda numba-cuda>=0.22.1
324+
- &numba_cuda_test numba-cuda>=0.22.1
303325
specific:
304326
- output_types: [requirements, pyproject]
305327
matrices:
306328
- matrix:
307329
cuda: "12.*"
308330
cuda_suffixed: "true"
309331
packages:
310-
- &numba_cuda_cu12 numba-cuda[cu12]>=0.22.1
332+
- &numba_cuda_cu12_test numba-cuda[cu12]>=0.22.1
311333
- matrix:
312334
cuda: "13.*"
313335
cuda_suffixed: "true"
314336
packages:
315-
- &numba_cuda_cu13 numba-cuda[cu13]>=0.22.1
337+
- &numba_cuda_cu13_test numba-cuda[cu13]>=0.22.1
316338
# fallback to numba-cuda with no extra CUDA packages if 'cuda_suffixed' isn't true
317339
- matrix:
318340
packages:
319-
- *numba_cuda
320-
run_python_distributed_ucxx:
341+
- *numba_cuda_test
342+
test_python_distributed_ucxx:
321343
common:
322344
- output_types: [conda, requirements, pyproject]
323345
packages:
324-
- rapids-dask-dependency==26.4.*,>=0.0.0a0
325-
- pyyaml>=6
346+
- *numpy
347+
- pytest<9.0.0
348+
- pytest-rerunfailures!=16.0.0 # See https://github.com/pytest-dev/pytest-rerunfailures/issues/302
326349
- output_types: [conda]
327350
packages:
328-
- *numba_cuda
351+
- *numba_cuda_test
329352
specific:
330353
- output_types: [requirements, pyproject]
331354
matrices:
332355
- matrix:
333356
cuda: "12.*"
334357
cuda_suffixed: "true"
335358
packages:
336-
- *numba_cuda_cu12
359+
- *numba_cuda_cu12_test
337360
- matrix:
338361
cuda: "13.*"
339362
cuda_suffixed: "true"
340363
packages:
341-
- *numba_cuda_cu13
342-
# fallback to numba-cuda with no extra CUDA packages if 'cuda_suffixed' isn't true
364+
- *numba_cuda_cu13_test
343365
- matrix:
344366
packages:
345-
- *numba_cuda
346-
test_cpp:
347-
common:
348-
- output_types: conda
349-
packages:
350-
- *cmake_ver
351-
test_python_ucxx:
352-
common:
353-
- output_types: [conda, requirements, pyproject]
354-
packages:
355-
- cloudpickle
356-
- pytest<9.0.0
357-
- pytest-asyncio>=1.0.0
358-
- pytest-rerunfailures!=16.0.0 # See https://github.com/pytest-dev/pytest-rerunfailures/issues/302
359-
- rapids-dask-dependency==26.4.*,>=0.0.0a0
360-
test_python_distributed_ucxx:
361-
common:
362-
- output_types: [conda, requirements, pyproject]
363-
packages:
364-
- *numpy
365-
- pytest<9.0.0
366-
- pytest-rerunfailures!=16.0.0 # See https://github.com/pytest-dev/pytest-rerunfailures/issues/302
367+
- *numba_cuda_test
367368
depends_on_cupy:
368369
common:
369370
- output_types: conda

python/distributed-ucxx/distributed_ucxx/ucxx.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION & AFFILIATES.
1+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES.
22
# SPDX-License-Identifier: BSD-3-Clause
33

44
"""
@@ -94,13 +94,12 @@ class CudaStream(Enum):
9494

9595

9696
def synchronize_stream(stream: CudaStream = CudaStream.Default):
97-
import numba.cuda
97+
from ucxx._cuda_context import synchronize_default_stream
9898

9999
if stream == CudaStream.Default:
100-
numba_stream = numba.cuda.default_stream()
100+
synchronize_default_stream()
101101
else:
102102
raise ValueError("Unsupported stream")
103-
numba_stream.synchronize()
104103

105104

106105
class gc_disabled:
@@ -246,11 +245,11 @@ def init_once():
246245
or ("cuda" in ucx_tls and "^cuda" not in ucx_tls)
247246
):
248247
try:
249-
import numba.cuda
250-
except ImportError:
248+
from ucxx._cuda_context import ensure_cuda_context
249+
except ImportError as e:
251250
raise ImportError(
252-
"CUDA support with UCX requires Numba for context management"
253-
)
251+
"CUDA support with UCX requires cuda-core for context management."
252+
) from e
254253

255254
cuda_visible_device = get_device_index_and_uuid(
256255
os.environ.get("CUDA_VISIBLE_DEVICES", "0").split(",")[0]
@@ -261,7 +260,7 @@ def init_once():
261260
pre_existing_cuda_context.device_info, os.getpid()
262261
)
263262

264-
numba.cuda.current_context()
263+
ensure_cuda_context(0)
265264

266265
cuda_context_created = has_cuda_context()
267266
if (
@@ -291,7 +290,8 @@ def init_once():
291290

292291
pool_size_str = get_rmm_config("pool-size")
293292

294-
# Find the function, `cuda_array()`, to use when allocating new CUDA arrays
293+
# Find the function, `cuda_array()`, to use when allocating new CUDA arrays.
294+
# RMM is required for CUDA array allocation at runtime (numba is only for tests).
295295
try:
296296
import rmm
297297

@@ -304,22 +304,9 @@ def device_array(n):
304304
pool_allocator=True, managed_memory=False, initial_pool_size=pool_size
305305
)
306306
except ImportError:
307-
try:
308-
import numba.cuda
309-
310-
def numba_device_array(n):
311-
a = numba.cuda.device_array((n,), dtype="u1")
312-
weakref.finalize(a, numba.cuda.current_context)
313-
return a
314-
315-
device_array = numba_device_array
316307

317-
except ImportError:
318-
319-
def device_array(n):
320-
raise RuntimeError(
321-
"In order to send/recv CUDA arrays, Numba or RMM is required"
322-
)
308+
def device_array(n):
309+
raise RuntimeError("In order to send/recv CUDA arrays, RMM is required.")
323310

324311
if pool_size_str is not None:
325312
logger.warning(

python/distributed-ucxx/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ license = "BSD-3-Clause"
2020
license-files = ["LICENSE"]
2121
requires-python = ">=3.11"
2222
dependencies = [
23-
"numba-cuda>=0.22.1",
23+
"cuda-core>=0.3.2",
2424
"pyyaml>=6",
2525
"rapids-dask-dependency==26.4.*,>=0.0.0a0",
2626
"ucxx==0.49.*,>=0.0.0a0",
@@ -46,6 +46,7 @@ docs = [
4646
test = [
4747
"cudf==26.4.*,>=0.0.0a0",
4848
"cupy-cuda13x>=13.6.0",
49+
"numba-cuda>=0.22.1",
4950
"numpy>=1.23,<3.0",
5051
"pytest-rerunfailures!=16.0.0",
5152
"pytest<9.0.0",

python/ucxx/examples/basic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES.
1+
# SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES.
22
# SPDX-License-Identifier: BSD-3-Clause
33

44
import argparse
@@ -12,9 +12,9 @@
1212

1313

1414
def _create_cuda_context():
15-
import numba.cuda
15+
from ucxx._cuda_context import ensure_cuda_context
1616

17-
numba.cuda.current_context()
17+
ensure_cuda_context(0)
1818

1919

2020
async def _progress_coroutine(worker):

python/ucxx/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ authors = [
1919
license = "BSD-3-Clause"
2020
requires-python = ">=3.11"
2121
dependencies = [
22+
"cuda-core>=0.3.2",
2223
"libucxx==0.49.*,>=0.0.0a0",
23-
"numba-cuda>=0.22.1",
2424
"numpy>=1.23,<3.0",
2525
"nvidia-ml-py>=12",
2626
"rmm==26.4.*,>=0.0.0a0",
@@ -44,6 +44,7 @@ test = [
4444
"cloudpickle",
4545
"cudf==26.4.*,>=0.0.0a0",
4646
"cupy-cuda13x>=13.6.0",
47+
"numba-cuda>=0.22.1",
4748
"pytest-asyncio>=1.0.0",
4849
"pytest-rerunfailures!=16.0.0",
4950
"pytest<9.0.0",

0 commit comments

Comments
 (0)