From 5e93ec07f325569d87a4f1b615bbce1046005c0a Mon Sep 17 00:00:00 2001 From: Algorithm5838 <108630393+Algorithm5838@users.noreply.github.com> Date: Mon, 6 Apr 2026 10:17:28 +0300 Subject: [PATCH] perf: skip torch import on non-macOS --- backend/open_webui/env.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/backend/open_webui/env.py b/backend/open_webui/env.py index e0dcaff276..53737a1f2f 100644 --- a/backend/open_webui/env.py +++ b/backend/open_webui/env.py @@ -60,13 +60,14 @@ if USE_CUDA.lower() == 'true': else: DEVICE_TYPE = 'cpu' -try: - import torch +if sys.platform == 'darwin': + try: + import torch - if torch.backends.mps.is_available() and torch.backends.mps.is_built(): - DEVICE_TYPE = 'mps' -except Exception: - pass + if torch.backends.mps.is_available() and torch.backends.mps.is_built(): + DEVICE_TYPE = 'mps' + except Exception: + pass #################################### # LOGGING