mirror of
https://github.com/open-webui/open-webui.git
synced 2026-03-10 07:43:10 -05:00
fix: Apple Silicon test fails pytorch not imported #3205
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @richtong on GitHub (Jan 6, 2025).
Bug Report
Installation Method
Installation was pipx install open-webui and also git clone of repo and running npm run dev for frontend and dev.sh in backend
Environment
Open WebUI Version: v0.5.4
Ollama (if applicable): 0.5.4
Operating System: MacOS Sequoia 15.2
Browser (if applicable): Brave v1.73.104
Confirmation:
Expected Behavior:
On Apple Silicon, DEVICE_TYPE="mps" to enable GPU acceleration
Actual Behavior:
On Apple Silicon M4 Max, the check for a pytorch device silently fails because the exception that torch is not loaded, the import for torch currently only happens if CUDA_DEVICE is requested.
Description
Bug Summary:
The current test is, but torch is not imported (this only happens if USE_CUDA=true, there is no top level import. The test fails because torch is not loaded and since the exceptions are ignored, DEVICE_TYPE="cpu" is left as it is and the user gets no explanation. Fix is in https://github.com/open-webui/open-webui/pull/8366
The fix (although ugly) is to import torch in the try loop and also to print the actual
exception (it looks like logging is not used in this part of the code and print to stdout)
is what happens
Reproduction Details
Steps to Reproduce:
Logs and Screenshots
Browser Console Logs:
N/A
Docker Container Logs:
N/A install from repo or pipx install
Screenshots/Screen Recordings (if applicable):
I can include an Activity monitor if you want
Additional Information
Having two import pytorch in the Apple Silicon and the CUDA test is kind of ugly but the minimum code change, you probably just want to wrap the entire test section in a Try/except rather than having two, but presume you want the msalled rewrite
Note
If the bug report is incomplete or does not follow the provided instructions, it may not be addressed. Please ensure that you have followed the steps outlined in the README.md and troubleshooting.md documents, and provide all necessary information for us to reproduce and address the issue. Thank you!
@richtong commented on GitHub (Jan 18, 2025):
Thanks all!