Skip to content

Commit a2eb58a

Browse files
committed
✅ Skip GPU test if GPU is not available (e.g in github env)
1 parent fd52b30 commit a2eb58a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/test_gpu.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Test PCA with GPU and different dtypes."""
22

3-
# Copyright (c) 2024 Valentin Goldité. All Rights Reserved.
3+
# Copyright (c) 2024 Valentin Goldité. All Rights Reserved
4+
import pytest
45
import pytest_check as check
56
import torch
67

@@ -9,6 +10,8 @@
910

1011
def test_gpu() -> None:
1112
"""Test with GPU and different dtypes."""
13+
if not torch.cuda.is_available():
14+
pytest.skip("No GPU found.")
1215
inputs = torch.load("tests/input_data.pt").to("cuda:0")
1316
for dtype in [torch.float32, torch.float16, torch.float64]:
1417
inputs = inputs.to(dtype)

0 commit comments

Comments
 (0)