Skip to content
Snippets Groups Projects
Commit d10c65d4 authored by Richard Angersbach's avatar Richard Angersbach
Browse files

Catch CUDARuntimeError for mising CUDA capable device in reduction GPU test

parent 99125ca7
No related branches found
No related tags found
1 merge request!438Reduction Support
......@@ -2,6 +2,7 @@ import pytest
import numpy as np
import pystencils as ps
from cupy_backends.cuda.api.runtime import CUDARuntimeError
from pystencils.sympyextensions import reduction_assignment_from_str
INIT_W = 5
......@@ -48,8 +49,15 @@ def test_reduction_cpu(instruction_set, dtype, op):
@pytest.mark.parametrize('dtype', ["float64", "float32"])
@pytest.mark.parametrize("op", ["+", "-", "*", "min", "max"])
def test_reduction_gpu(dtype, op):
pytest.importorskip('cupy')
import cupy as cp
try:
import cupy as cp
device_count = range(cp.cuda.runtime.getDeviceCount())
print(f"Found {device_count} GPUs")
except ImportError:
pytest.skip(reason="CuPy is not available", allow_module_level=True)
except CUDARuntimeError:
pytest.skip(reason="No CUDA capable device is detected", allow_module_level=True)
config = ps.CreateKernelConfig(target=ps.Target.GPU)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment