Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_process_device throws an error on when cuda is available #1047

Closed
janfb opened this issue Mar 20, 2024 · 0 comments
Closed

test_process_device throws an error on when cuda is available #1047

janfb opened this issue Mar 20, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@janfb
Copy link
Contributor

janfb commented Mar 20, 2024

Describe the bug
The test for device handling seems to require the wrong output. It should not fail on a cuda capable machine.

To Reproduce
pytest tests/torchutils_test.py::test_process_device

Expected behavior
the test should pass.

Additional context

...............xxxx......x............................................................................................. [100%]
============================================================ FAILURES ============================================================
___________________________________________________ test_process_device[cuda] ____________________________________________________

device_input = 'cuda'

@pytest.mark.parametrize("device_input", ("cpu", "gpu", "cuda", "cuda:0", "mps"))
def test_process_device(device_input: str) -> None:
    """Test whether the device is processed correctly."""

    try:
        device_output = torchutils.process_device(device_input)
        if device_input == "cpu":
            assert device_output == "cpu"
        elif device_input == "gpu":
            if torch.cuda.is_available():
                current_gpu_index = torch.cuda.current_device()
                assert device_output == f"cuda:{current_gpu_index}"
            elif torch.backends.mps.is_available():
                assert device_output == "mps:0"

        if device_input == "cuda" and torch.cuda.is_available():
          assert device_output == "cuda:0"

E AssertionError: assert 'cuda' == 'cuda:0'
E
E - cuda:0
E ? --
E + cuda

../sbi/tests/torchutils_test.py:219: AssertionError

@janfb janfb added the bug Something isn't working label Mar 20, 2024
@janfb janfb added this to the Hackathon 2024 milestone Mar 20, 2024
@janfb janfb self-assigned this Mar 20, 2024
janfb added a commit that referenced this issue Apr 12, 2024
@janfb janfb closed this as completed in 0b5f931 Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant