Skip to content

Commit 3ceeb82

Browse files
Algorithm5838github-actions[bot]
authored andcommitted
perf: skip torch import on non-macOS
1 parent 9b51d65 commit 3ceeb82

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

backend/open_webui/env.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@
6060
else:
6161
DEVICE_TYPE = 'cpu'
6262

63-
try:
64-
import torch
63+
if sys.platform == 'darwin':
64+
try:
65+
import torch
6566

66-
if torch.backends.mps.is_available() and torch.backends.mps.is_built():
67-
DEVICE_TYPE = 'mps'
68-
except Exception:
69-
pass
67+
if torch.backends.mps.is_available() and torch.backends.mps.is_built():
68+
DEVICE_TYPE = 'mps'
69+
except Exception:
70+
pass
7071

7172
####################################
7273
# LOGGING

0 commit comments

Comments
 (0)