|
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
4 | 4 | import ctypes |
5 | | -import functools |
6 | 5 | import os |
7 | 6 | import platform |
8 | 7 | import sys |
9 | 8 | from contextlib import suppress |
10 | | -from typing import Union |
11 | | - |
12 | | -from cuda.core._utils.cuda_utils import handle_return |
13 | 9 |
|
14 | 10 | __all__ = [ |
15 | 11 | "IS_WINDOWS", |
16 | 12 | "IS_WSL", |
17 | 13 | "libc", |
18 | | - "supports_ipc_mempool", |
19 | 14 | "under_compute_sanitizer", |
20 | 15 | ] |
21 | 16 |
|
@@ -68,38 +63,3 @@ def under_compute_sanitizer() -> bool: |
68 | 63 | # Another common indicator: sanitizer injectors are configured via env vars. |
69 | 64 | inj = os.environ.get("CUDA_INJECTION64_PATH", "") |
70 | 65 | return "compute-sanitizer" in inj or "cuda-memcheck" in inj |
71 | | - |
72 | | - |
73 | | -@functools.cache |
74 | | -def supports_ipc_mempool(device_id: Union[int, object]) -> bool: |
75 | | - """Return True if mempool IPC via POSIX file descriptor is supported. |
76 | | -
|
77 | | - Uses cuDeviceGetAttribute(CU_DEVICE_ATTRIBUTE_MEMPOOL_SUPPORTED_HANDLE_TYPES) |
78 | | - to check for CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR support. Does not |
79 | | - require an active CUDA context. |
80 | | - """ |
81 | | - if _detect_wsl(): |
82 | | - return False |
83 | | - |
84 | | - try: |
85 | | - # Lazy import to avoid hard dependency when not running GPU tests |
86 | | - try: |
87 | | - from cuda.bindings import driver # type: ignore |
88 | | - except Exception: |
89 | | - from cuda import cuda as driver # type: ignore |
90 | | - |
91 | | - # Initialize CUDA |
92 | | - handle_return(driver.cuInit(0)) |
93 | | - |
94 | | - # Resolve device id from int or Device-like object |
95 | | - dev_id = int(getattr(device_id, "device_id", device_id)) |
96 | | - |
97 | | - # Query supported mempool handle types bitmask |
98 | | - attr = driver.CUdevice_attribute.CU_DEVICE_ATTRIBUTE_MEMPOOL_SUPPORTED_HANDLE_TYPES |
99 | | - mask = handle_return(driver.cuDeviceGetAttribute(attr, dev_id)) |
100 | | - |
101 | | - # Check POSIX FD handle type support via bitmask |
102 | | - posix_fd = driver.CUmemAllocationHandleType.CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR |
103 | | - return (int(mask) & int(posix_fd)) != 0 |
104 | | - except Exception: |
105 | | - return False |
0 commit comments