-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved torch_device setting to root conftest
- Loading branch information
1 parent
1c94736
commit 519c7c6
Showing
2 changed files
with
19 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
|
||
import pytest | ||
import torch | ||
from cellfinder.core.tools.system import force_cpu | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def set_device_arm_macos_ci(): | ||
""" | ||
Ensure that the device is set to CPU when running on arm based macOS | ||
GitHub runners. This is to avoid the following error: | ||
https://discuss.pytorch.org/t/mps-back-end-out-of-memory-on-github-action/189773/5 | ||
""" | ||
if ( | ||
os.getenv("GITHUB_ACTIONS") == "true" | ||
and torch.backends.mps.is_available() | ||
): | ||
force_cpu() | ||