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

Bug: _select_device_and_dtype does not work on virtualized hardware #232

Closed
ibevers opened this issue Jan 2, 2025 · 4 comments · Fixed by #234
Closed

Bug: _select_device_and_dtype does not work on virtualized hardware #232

ibevers opened this issue Jan 2, 2025 · 4 comments · Fixed by #234
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ibevers
Copy link
Collaborator

ibevers commented Jan 2, 2025

Description

I ran into this issue because MacOS tests were passing locally, but not on GitHub Actions. It is because _select_device_and_dtype selected MPS on the MacOS GitHub Actions runner, but the runner virtualizes MacOS, so no MPS device is available.

See details here:
#215

Steps to Reproduce

Run code with DeviceType.MPS on a GitHub Actions MacOS runner (ARM).

Expected Results

The tests will segfault.

Actual Results

The tests segfaulted.

Additional Notes

No response

@ibevers ibevers added the bug Something isn't working label Jan 2, 2025
@ibevers ibevers mentioned this issue Jan 2, 2025
6 tasks
@fabiocat93
Copy link
Collaborator

@ibevers
Copy link
Collaborator Author

ibevers commented Jan 10, 2025

@fabiocat93 This could come up in other contexts though too. Perhaps we could add a try/except that tries to run something on MPS in the function? We could do the same thing for GPU.

if torch.backends.mps.is_available():
    try:
        torch.empty(0, device="mps")
        available_devices.append(DeviceType.MPS)
    except Exception as e:
        print(f"MPS is available but encountered an error: {e}")

@fabiocat93
Copy link
Collaborator

@fabiocat93 This could come up in other contexts though too. Perhaps we could add a try/except that tries to run something on MPS in the function? We could do the same thing for GPU.

if torch.backends.mps.is_available():
    try:
        torch.empty(0, device="mps")
        available_devices.append(DeviceType.MPS)
    except Exception as e:
        print(f"MPS is available but encountered an error: {e}")

Have you tested this on the GitHub runner? Does it solve the issue you describe above? If yes, it looks a good solution to me. I agree with you that we should apply the same approach to GPU. Also, I would recommend adding a comment explaining the rationale behind these edits

@ibevers
Copy link
Collaborator Author

ibevers commented Jan 13, 2025

@fabiocat93 I haven't tested it yet--I just wanted to see what you thought of that approach in concept. I will make proper PR and test. Thanks for your feedback!

@ibevers ibevers linked a pull request Jan 13, 2025 that will close this issue
6 tasks
@fabiocat93 fabiocat93 added the help wanted Extra attention is needed label Jan 15, 2025
@ibevers ibevers self-assigned this Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants