aboutsummaryrefslogtreecommitdiff
path: root/modules/devices.py
diff options
context:
space:
mode:
authorIvan <ivan.demian2009@gmail.com>2023-01-27 17:21:48 +0500
committerGitHub <noreply@github.com>2023-01-27 17:21:48 +0500
commit63391419c11c1749a3d83dade19235a836c509f9 (patch)
tree5781c7fe6de7a61bb5936956e68e0582f03d7f6c /modules/devices.py
parentf5d73b6a6646b51027c8e6f6c6154f21b58d6af2 (diff)
parent9beb794e0b0dc1a0f9e89d8e38bd789a8c608397 (diff)
Merge branch 'AUTOMATIC1111:master' into master
Diffstat (limited to 'modules/devices.py')
-rw-r--r--modules/devices.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/modules/devices.py b/modules/devices.py
index 6b36622c..4687944e 100644
--- a/modules/devices.py
+++ b/modules/devices.py
@@ -34,14 +34,18 @@ def get_cuda_device_string():
return "cuda"
-def get_optimal_device():
+def get_optimal_device_name():
if torch.cuda.is_available():
- return torch.device(get_cuda_device_string())
+ return get_cuda_device_string()
if has_mps():
- return torch.device("mps")
+ return "mps"
+
+ return "cpu"
- return cpu
+
+def get_optimal_device():
+ return torch.device(get_optimal_device_name())
def get_device_for(task):
@@ -139,6 +143,8 @@ def test_for_nans(x, where):
else:
message = "A tensor with all NaNs was produced."
+ message += " Use --disable-nan-check commandline argument to disable this check."
+
raise NansException(message)