Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cuda_bindings/tests/nvml/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest

from cuda.bindings import nvml
from cuda_python_test_helpers import driver_version_less_than


def assert_nvml_is_initialized():
Expand Down Expand Up @@ -43,6 +44,7 @@ def get_architecture_name(arch):

@pytest.mark.skipif(sys.platform == "win32", reason="Test not supported on Windows")
@pytest.mark.thread_unsafe(reason="nvml init affects other threads")
@pytest.mark.skipif(not driver_version_less_than(13040), reason="Init behavior changed in CUDA 13.4")
def test_init_ref_count():
"""
Verifies that we can call NVML shutdown and init(2) multiple times, and that ref counting works
Expand Down
49 changes: 22 additions & 27 deletions cuda_bindings/tests/test_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@
import cuda.bindings.driver as cuda
import cuda.bindings.runtime as cudart
from cuda.bindings import driver


def driverVersionLessThan(target):
(err,) = cuda.cuInit(0)
assert err == cuda.CUresult.CUDA_SUCCESS
err, version = cuda.cuDriverGetVersion()
assert err == cuda.CUresult.CUDA_SUCCESS
return version < target
from cuda_python_test_helpers import driver_version_less_than


def supportsMemoryPool():
Expand Down Expand Up @@ -265,7 +258,7 @@ def test_cuda_CUstreamBatchMemOpParams():


@pytest.mark.skipif(
driverVersionLessThan(11030) or not supportsMemoryPool(), reason="When new attributes were introduced"
driver_version_less_than(11030) or not supportsMemoryPool(), reason="When new attributes were introduced"
)
def test_cuda_memPool_attr():
poolProps = cuda.CUmemPoolProps()
Expand Down Expand Up @@ -328,7 +321,7 @@ def test_cuda_memPool_attr():


@pytest.mark.skipif(
driverVersionLessThan(11030) or not supportsManagedMemory(), reason="When new attributes were introduced"
driver_version_less_than(11030) or not supportsManagedMemory(), reason="When new attributes were introduced"
)
def test_cuda_pointer_attr():
err, ptr = cuda.cuMemAllocManaged(0x1000, cuda.CUmemAttach_flags.CU_MEM_ATTACH_GLOBAL.value)
Expand Down Expand Up @@ -379,7 +372,7 @@ def test_cuda_pointer_attr():


@pytest.mark.skipif(
driverVersionLessThan(11030) or not supportsManagedMemory(), reason="When new attributes were introduced"
driver_version_less_than(11030) or not supportsManagedMemory(), reason="When new attributes were introduced"
)
def test_pointer_get_attributes_device_ordinal():
attributes = [
Expand Down Expand Up @@ -457,7 +450,9 @@ def test_cuda_mem_range_attr(device):
assert err == cuda.CUresult.CUDA_SUCCESS


@pytest.mark.skipif(driverVersionLessThan(11040) or not supportsMemoryPool(), reason="Mempool for graphs not supported")
@pytest.mark.skipif(
driver_version_less_than(11040) or not supportsMemoryPool(), reason="Mempool for graphs not supported"
)
@pytest.mark.thread_unsafe(reason="used high memory can be higher if threaded.")
def test_cuda_graphMem_attr(device):
err, stream = cuda.cuStreamCreate(0)
Expand Down Expand Up @@ -516,7 +511,7 @@ def test_cuda_graphMem_attr(device):


@pytest.mark.skipif(
driverVersionLessThan(12010)
driver_version_less_than(12010)
or not supportsCudaAPI("cuCoredumpSetAttributeGlobal")
or not supportsCudaAPI("cuCoredumpGetAttributeGlobal"),
reason="Coredump API not present",
Expand Down Expand Up @@ -566,7 +561,7 @@ def test_get_error_name_and_string():


# TODO: cuStreamGetCaptureInfo_v2
@pytest.mark.skipif(driverVersionLessThan(11030), reason="Driver too old for cuStreamGetCaptureInfo_v2")
@pytest.mark.skipif(driver_version_less_than(11030), reason="Driver too old for cuStreamGetCaptureInfo_v2")
def test_stream_capture():
pass

Expand Down Expand Up @@ -636,7 +631,7 @@ def test_invalid_repr_attribute():


@pytest.mark.skipif(
driverVersionLessThan(12020)
driver_version_less_than(12020)
or not supportsCudaAPI("cuGraphAddNode")
or not supportsCudaAPI("cuGraphNodeSetParams")
or not supportsCudaAPI("cuGraphExecNodeSetParams"),
Expand Down Expand Up @@ -748,7 +743,7 @@ def test_graph_poly():


@pytest.mark.skipif(
driverVersionLessThan(12040) or not supportsCudaAPI("cuDeviceGetDevResource"),
driver_version_less_than(12040) or not supportsCudaAPI("cuDeviceGetDevResource"),
reason="Polymorphic graph APIs required",
)
def test_cuDeviceGetDevResource(device):
Expand All @@ -768,7 +763,7 @@ def test_cuDeviceGetDevResource(device):


@pytest.mark.skipif(
driverVersionLessThan(12030) or not supportsCudaAPI("cuGraphConditionalHandleCreate"),
driver_version_less_than(12030) or not supportsCudaAPI("cuGraphConditionalHandleCreate"),
reason="Conditional graph APIs required",
)
def test_conditional(ctx):
Expand Down Expand Up @@ -830,22 +825,22 @@ def test_all_CUresult_codes():
assert num_good >= 76 # CTK 11.0.3_450.51.06


@pytest.mark.skipif(driverVersionLessThan(12030), reason="Driver too old for cuKernelGetName")
@pytest.mark.skipif(driver_version_less_than(12030), reason="Driver too old for cuKernelGetName")
def test_cuKernelGetName_failure():
err, name = cuda.cuKernelGetName(0)
assert err == cuda.CUresult.CUDA_ERROR_INVALID_VALUE
assert name is None


@pytest.mark.skipif(driverVersionLessThan(12030), reason="Driver too old for cuFuncGetName")
@pytest.mark.skipif(driver_version_less_than(12030), reason="Driver too old for cuFuncGetName")
def test_cuFuncGetName_failure():
err, name = cuda.cuFuncGetName(0)
assert err == cuda.CUresult.CUDA_ERROR_INVALID_VALUE
assert name is None


@pytest.mark.skipif(
driverVersionLessThan(12080) or not supportsCudaAPI("cuCheckpointProcessGetState"),
driver_version_less_than(12080) or not supportsCudaAPI("cuCheckpointProcessGetState"),
reason="When API was introduced",
)
def test_cuCheckpointProcessGetState_failure():
Expand Down Expand Up @@ -887,7 +882,7 @@ def test_struct_pointer_comparison(target):


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cuGraphGetId"),
driver_version_less_than(13010) or not supportsCudaAPI("cuGraphGetId"),
reason="Requires CUDA 13.1+",
)
def test_cuGraphGetId(device, ctx):
Expand All @@ -914,7 +909,7 @@ def test_cuGraphGetId(device, ctx):


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cuGraphExecGetId"),
driver_version_less_than(13010) or not supportsCudaAPI("cuGraphExecGetId"),
reason="Requires CUDA 13.1+",
)
def test_cuGraphExecGetId(device, ctx):
Expand Down Expand Up @@ -1040,7 +1035,7 @@ def test_cuGraphNodeGetDependencies_edgeData_outlives_call(device, ctx):


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cuGraphNodeGetLocalId"),
driver_version_less_than(13010) or not supportsCudaAPI("cuGraphNodeGetLocalId"),
reason="Requires CUDA 13.1+",
)
def test_cuGraphNodeGetLocalId(device, ctx):
Expand Down Expand Up @@ -1082,7 +1077,7 @@ def test_cuGraphNodeGetLocalId(device, ctx):


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cuGraphNodeGetToolsId"),
driver_version_less_than(13010) or not supportsCudaAPI("cuGraphNodeGetToolsId"),
reason="Requires CUDA 13.1+",
)
def test_cuGraphNodeGetToolsId(device, ctx):
Expand Down Expand Up @@ -1111,7 +1106,7 @@ def test_cuGraphNodeGetToolsId(device, ctx):


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cuGraphNodeGetContainingGraph"),
driver_version_less_than(13010) or not supportsCudaAPI("cuGraphNodeGetContainingGraph"),
reason="Requires CUDA 13.1+",
)
def test_cuGraphNodeGetContainingGraph(device, ctx):
Expand Down Expand Up @@ -1158,7 +1153,7 @@ def test_cuGraphNodeGetContainingGraph(device, ctx):


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cuStreamGetDevResource"),
driver_version_less_than(13010) or not supportsCudaAPI("cuStreamGetDevResource"),
reason="Requires CUDA 13.1+",
)
def test_cuStreamGetDevResource(device, ctx):
Expand All @@ -1177,7 +1172,7 @@ def test_cuStreamGetDevResource(device, ctx):


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cuDevSmResourceSplit"),
driver_version_less_than(13010) or not supportsCudaAPI("cuDevSmResourceSplit"),
reason="Requires CUDA 13.1+",
)
def test_cuDevSmResourceSplit(device, ctx):
Expand Down
43 changes: 19 additions & 24 deletions cuda_bindings/tests/test_cudart.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import cuda.bindings.runtime as cudart
from cuda import pathfinder
from cuda.bindings import runtime
from cuda_python_test_helpers import driver_version_less_than


def isSuccess(err):
Expand All @@ -22,12 +23,6 @@ def assertSuccess(err):
assert isSuccess(err)


def driverVersionLessThan(target):
err, version = cudart.cudaDriverGetVersion()
assertSuccess(err)
return version < target


def supportsMemoryPool():
err, isSupported = cudart.cudaDeviceGetAttribute(cudart.cudaDeviceAttr.cudaDevAttrMemoryPoolsSupported, 0)
return isSuccess(err) and isSupported
Expand Down Expand Up @@ -504,7 +499,7 @@ def test_cudart_cudaGetDeviceProperties():


@pytest.mark.skipif(
driverVersionLessThan(11030) or not supportsMemoryPool(), reason="When new attributes were introduced"
driver_version_less_than(11030) or not supportsMemoryPool(), reason="When new attributes were introduced"
)
def test_cudart_MemPool_attr():
poolProps = cudart.cudaMemPoolProps()
Expand Down Expand Up @@ -1445,7 +1440,7 @@ def test_cudart_func_callback():


@pytest.mark.skipif(
driverVersionLessThan(12030) or not supportsCudaAPI("cudaGraphConditionalHandleCreate"),
driver_version_less_than(12030) or not supportsCudaAPI("cudaGraphConditionalHandleCreate"),
reason="Conditional graph APIs required",
)
def test_cudart_conditional():
Expand Down Expand Up @@ -1503,7 +1498,7 @@ def test_getLocalRuntimeVersion():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaGraphGetId"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaGraphGetId"),
reason="Requires CUDA 13.1+",
)
def test_cudaGraphGetId():
Expand All @@ -1530,7 +1525,7 @@ def test_cudaGraphGetId():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaGraphExecGetId"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaGraphExecGetId"),
reason="Requires CUDA 13.1+",
)
def test_cudaGraphExecGetId():
Expand Down Expand Up @@ -1577,7 +1572,7 @@ def test_cudaGraphExecGetId():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaGraphNodeGetLocalId"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaGraphNodeGetLocalId"),
reason="Requires CUDA 13.1+",
)
def test_cudaGraphNodeGetLocalId():
Expand Down Expand Up @@ -1619,7 +1614,7 @@ def test_cudaGraphNodeGetLocalId():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaGraphNodeGetToolsId"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaGraphNodeGetToolsId"),
reason="Requires CUDA 13.1+",
)
def test_cudaGraphNodeGetToolsId():
Expand Down Expand Up @@ -1648,7 +1643,7 @@ def test_cudaGraphNodeGetToolsId():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaGraphNodeGetContainingGraph"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaGraphNodeGetContainingGraph"),
reason="Requires CUDA 13.1+",
)
def test_cudaGraphNodeGetContainingGraph():
Expand Down Expand Up @@ -1695,7 +1690,7 @@ def test_cudaGraphNodeGetContainingGraph():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaStreamGetDevResource"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaStreamGetDevResource"),
reason="Requires CUDA 13.1+",
)
def test_cudaStreamGetDevResource():
Expand All @@ -1714,7 +1709,7 @@ def test_cudaStreamGetDevResource():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaDeviceGetDevResource"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaDeviceGetDevResource"),
reason="Requires CUDA 13.1+",
)
def test_cudaDeviceGetDevResource():
Expand All @@ -1729,7 +1724,7 @@ def test_cudaDeviceGetDevResource():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaDeviceGetExecutionCtx"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaDeviceGetExecutionCtx"),
reason="Requires CUDA 13.1+",
)
def test_cudaExecutionCtxGetDevResource():
Expand All @@ -1747,7 +1742,7 @@ def test_cudaExecutionCtxGetDevResource():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaDeviceGetExecutionCtx"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaDeviceGetExecutionCtx"),
reason="Requires CUDA 13.1+",
)
def test_cudaExecutionCtxGetDevice():
Expand All @@ -1767,7 +1762,7 @@ def test_cudaExecutionCtxGetDevice():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaDeviceGetExecutionCtx"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaDeviceGetExecutionCtx"),
reason="Requires CUDA 13.1+",
)
def test_cudaExecutionCtxGetId():
Expand Down Expand Up @@ -1795,7 +1790,7 @@ def test_cudaExecutionCtxGetId():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaDevSmResourceSplit"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaDevSmResourceSplit"),
reason="Requires CUDA 13.1+",
)
def test_cudaDevSmResourceSplit():
Expand Down Expand Up @@ -1864,7 +1859,7 @@ def test_cudaDevSmResourceSplit():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaDevSmResourceSplitByCount"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaDevSmResourceSplitByCount"),
reason="Requires CUDA 13.1+",
)
def test_cudaDevSmResourceSplitByCount():
Expand All @@ -1887,7 +1882,7 @@ def test_cudaDevSmResourceSplitByCount():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaDevResourceGenerateDesc"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaDevResourceGenerateDesc"),
reason="Requires CUDA 13.1+",
)
def test_cudaDevResourceGenerateDesc():
Expand All @@ -1904,7 +1899,7 @@ def test_cudaDevResourceGenerateDesc():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaGreenCtxCreate"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaGreenCtxCreate"),
reason="Requires CUDA 13.1+",
)
def test_cudaGreenCtxCreate():
Expand Down Expand Up @@ -1935,7 +1930,7 @@ def test_cudaGreenCtxCreate():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaExecutionCtxStreamCreate"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaExecutionCtxStreamCreate"),
reason="Requires CUDA 13.1+",
)
def test_cudaExecutionCtxStreamCreate():
Expand All @@ -1956,7 +1951,7 @@ def test_cudaExecutionCtxStreamCreate():


@pytest.mark.skipif(
driverVersionLessThan(13010) or not supportsCudaAPI("cudaGraphConditionalHandleCreate_v2"),
driver_version_less_than(13010) or not supportsCudaAPI("cudaGraphConditionalHandleCreate_v2"),
reason="Requires CUDA 13.1+",
)
def test_cudaGraphConditionalHandleCreate_v2():
Expand Down
Loading