def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
    """Automatically mark tests as 'cpu' unless they're marked as 'gpu'."""
    for item in items:
        if not any(marker.name == "gpu" for marker in item.iter_markers()):
            item.add_marker(pytest.mark.cpu)
Automatically mark tests as 'cpu' unless they're marked as 'gpu'.
tests/conftest.py