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

Add the possibility to manually test on cuda devices #573

Closed
schroedk opened this issue May 3, 2024 · 0 comments · Fixed by #574
Closed

Add the possibility to manually test on cuda devices #573

schroedk opened this issue May 3, 2024 · 0 comments · Fixed by #574
Assignees
Labels
enhancement New feature or request testing Writing and verifying tests (unit or otherwise)
Milestone

Comments

@schroedk
Copy link
Collaborator

schroedk commented May 3, 2024

To test the device handling of our torch related code, we should add the possibility to manually run tests with cuda
support.

Suggestion:

  • Add --with-cuda option:

    parser.addoption(
            "--with-cuda",
            action="store_true",
            default=False,
            help="Use CUDA for testing if available",
        )
  • Add a device fixture, which can be used in tests:

    @pytest.fixture(scope="session")
    def device(request):
        import torch
    
        use_cuda = request.config.getoption("--with-cuda")
        if use_cuda and torch.cuda.is_available():
            return torch.device("cuda")
        else:
            return torch.device("cpu")
  • manually run pytest --with-cuda

@schroedk schroedk added enhancement New feature or request testing Writing and verifying tests (unit or otherwise) labels May 3, 2024
@schroedk schroedk added this to the v0.9.2 milestone May 3, 2024
@schroedk schroedk self-assigned this May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request testing Writing and verifying tests (unit or otherwise)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant