Skip to content

[BUG]: The symbol table requires protection for thread-safety #852

Description

@pentschev

Is this a duplicate?

Type of Bug

Runtime Error

Component

cuda.bindings

Describe the bug

Multi-threaded applications may attempt to access the symbol table simultaneously before it's populated and cause concurrency issues, as observed previously.

Sample failure stack
/opt/conda/envs/test/lib/python3.12/site-packages/numba_cuda/numba/cuda/cudadrv/devices.py:125: inensure_contextwithdriver.get_active_context():
^^^^^^^^^^^^^^^^^^^^^^^^^^^/opt/conda/envs/test/lib/python3.12/site-packages/numba_cuda/numba/cuda/cudadrv/driver.py:539: in__enter__hctx=driver.cuCtxGetCurrent()
^^^^^^^^^^^^^^^^^^^^^^^^/opt/conda/envs/test/lib/python3.12/site-packages/numba_cuda/numba/cuda/cudadrv/driver.py:396: insafe_cuda_api_callreturnself._check_cuda_python_error(fname, libfn(*args))
^^^^^^^^^^^^cuda/bindings/driver.pyx:20135: incuda.bindings.driver.cuCtxGetCurrent
???
cuda/bindings/cydriver.pyx:107: incuda.bindings.cydriver.cuCtxGetCurrent
???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > ???
ERuntimeError: Function"cuCtxGetCurrent"notfound

This should have been already addressed by #835.

How to Reproduce

No known trivial reproducer, consistently observed with this test from RapidsMPF and numba-cuda=0.18.1 (required to ensure it's using cuda-bindings, instead of its own ctypes implementation):

Reproducer
@pytest.mark.parametrize("partition_count", [None, 3])@pytest.mark.parametrize("sort", [True, False])@pytest.mark.parametrize("cluster_kind", ["auto", "single"])deftest_dask_cudf_integration_single(
partition_count: int,
sort: bool, # noqa: FBT001cluster_kind: Literal["distributed", "single", "auto"],
) ->None:
# Test single-worker cuDF integration with Dask-cuDFpytest.importorskip("dask_cudf")
df= (
dask.datasets.timeseries(
freq="3600s",
partition_freq="2D",
)
.reset_index(drop=True)
.to_backend("cudf")
)
partition_count_in=df.npartitionsexpect=df.compute().sort_values(["id", "name", "x", "y"])
shuffled=dask_cudf_shuffle(
df,
["id", "name"],
sort=sort,
partition_count=partition_count,
cluster_kind=cluster_kind,
config_options=Options({"single_spill_device": "0.1"}),
)
assertshuffled.npartitions== (partition_countorpartition_count_in)
got=shuffled.compute()
ifsort:
assertgot["id"].is_monotonic_increasinggot=got.sort_values(["id", "name", "x", "y"])
dd.assert_eq(expect, got, check_index=False)

Expected behavior

Attempting to create a CUDA context from multiple threads should not cause an error.

Operating System

No response

nvidia-smi output

No response

Metadata

Metadata

Assignees

Labels

P0High priority - Must do!bugSomething isn't workingcuda.bindingsEverything related to the cuda.bindings module

Type

No type

Projects

Status
Done

Relationships

None yet

Development

No branches or pull requests

Issue actions