-
Notifications
You must be signed in to change notification settings - Fork 278
Expand file tree
/
Copy pathconftest.py
More file actions
36 lines (27 loc) · 1.03 KB
/
conftest.py
File metadata and controls
36 lines (27 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
import pathlib
import sys
helpers_root = pathlib.Path(__file__).resolve().parents[2] / "cuda_python_test_helpers"
if helpers_root.is_dir() and str(helpers_root) not in sys.path:
# Prefer the in-repo helpers over any installed copy.
sys.path.insert(0, str(helpers_root))
import cuda.bindings.driver as cuda
import pytest
@pytest.fixture(scope="module")
def cuda_driver():
(err,) = cuda.cuInit(0)
assert err == cuda.CUresult.CUDA_SUCCESS
@pytest.fixture(scope="module")
def device(cuda_driver):
err, device = cuda.cuDeviceGet(0)
assert err == cuda.CUresult.CUDA_SUCCESS
return device
@pytest.fixture(scope="module", autouse=True)
def ctx(device):
# Construct context
err, ctx = cuda.cuCtxCreate(None, 0, device)
assert err == cuda.CUresult.CUDA_SUCCESS
yield ctx
(err,) = cuda.cuCtxDestroy(ctx)
assert err == cuda.CUresult.CUDA_SUCCESS