Skip to content

Commit dc4dfe8

Browse files
authored
BUG: Handle CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM correctly (#2076)
* BUG: Handle CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM correctly * Add test * Fix copyright year
1 parent e481335 commit dc4dfe8

4 files changed

Lines changed: 18 additions & 4 deletions

File tree

cuda_bindings/cuda/bindings/_bindings/cydriver.pyx.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ cdef int _cuPythonInit() except -1 nogil:
519519
cdef char libPath[260]
520520

521521
with gil, __symbol_lock:
522-
usePTDS = os.getenv('CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM', default=0)
522+
usePTDS = bool(int(os.getenv('CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM', default=0)))
523523

524524
# Load library
525525
libPath[0] = 0

cuda_bindings/cuda/bindings/_bindings/cyruntime.pyx.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cdef int _cudaPythonInit() except -1 nogil:
1515
global __usePTDS
1616

1717
with gil:
18-
__usePTDS = os.getenv('CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM', default=False)
18+
__usePTDS = bool(int(os.getenv('CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM', default=0)))
1919
__cudaPythonInit = True
2020
return __usePTDS
2121

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
.. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3+
4+
.. module:: cuda.bindings
5+
6+
``cuda-bindings`` 13.2.1 Release notes
7+
======================================
8+
9+
Bugfixes
10+
--------
11+
12+
* Per-thread default stream mode would be used whenever the
13+
``CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM`` environment variable was set,
14+
even if it was set to ``0``.

scripts/run_tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44
# SPDX-License-Identifier: Apache-2.0
55

66
set -euo pipefail
@@ -133,7 +133,7 @@ status_from_rc() {
133133
run_pytest() {
134134
# Run pytest safely under set -e and return its exit code
135135
set +e
136-
python -m pytest "${PYTEST_FLAGS[@]}" "$@"
136+
CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM=0 python -m pytest "${PYTEST_FLAGS[@]}" "$@"
137137
local rc=$?
138138
set -e
139139
return ${rc}

0 commit comments

Comments
 (0)