fix: Force CPU processing on Mac to prevent SIGABRT crash#7
Closed
ShmuelOps wants to merge 1 commit into
Closed
Conversation
10 tasks
- Changed device selection to only force CPU on macOS (darwin) - Windows/Linux: Use CUDA if available, otherwise CPU - Prevents MPS (Metal Performance Shaders) memory issues on Mac - Fixes: Worker exited prematurely with signal 6 (SIGABRT) Platform Detection: - macOS (darwin): Force CPU to avoid MPS crashes - Windows/Linux: Use CUDA if available, otherwise CPU - Platform detected via sys.platform Tested on: macOS M4 Pro with 48GB RAM Impact: No more crashes on Mac, CUDA still works on Windows/Linux Technical Details: - Modified backend/workers/tasks.py line 197-207 - Uses sys.platform == 'darwin' to detect macOS - Preserves CUDA functionality for other platforms - Added debug logging for device selection per platform
a90017a to
7f860f3
Compare
Author
Update: Fixed to Preserve CUDA on Windows/LinuxI've updated this PR to only force CPU on macOS, while preserving CUDA support for Windows and Linux. What ChangedBefore (incorrect): device = "cpu" # Forced CPU on ALL platformsAfter (correct): if sys.platform == "darwin": # macOS only
device = "cpu"
print(f"[DEBUG] Detected macOS - forcing CPU to avoid MPS issues")
else: # Windows/Linux
device = "cuda" if torch.cuda.is_available() else "cpu"
print(f"[DEBUG] Using device: {device}")Impact
This ensures Mac users get stability while Windows/Linux users keep their GPU acceleration! |
Author
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Worker crashed with
signal 6 (SIGABRT)when loading AI models on Mac.Root Cause
MPS (Metal Performance Shaders) GPU memory exhaustion with bfloat16 precision on macOS.
Solution
Force CPU processing only on macOS while preserving CUDA support for Windows/Linux.
Platform-Specific Behavior
sys.platform == 'darwin'Changes
backend/workers/tasks.py(lines 197-207)if sys.platform == 'darwin'device = 'cpu'device = 'cuda' if torch.cuda.is_available() else 'cpu'Impact
✅ macOS Users
✅ Windows/Linux Users
Testing
Performance Trade-offs
macOS (CPU Processing)
smallorbasemodelsWindows/Linux (CUDA Processing)
Fixes: Worker exited prematurely: signal 6 (SIGABRT) on macOS