-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_macos_mutex.sh
More file actions
executable file
·42 lines (36 loc) · 1.49 KB
/
fix_macos_mutex.sh
File metadata and controls
executable file
·42 lines (36 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# Fix for macOS mutex crash with diffusers/PyTorch
echo "=== Fixing macOS PyTorch/Diffusers Mutex Issue ==="
echo ""
echo "This will:"
echo "1. Uninstall current torch/diffusers"
echo "2. Install CPU-only PyTorch (more stable on macOS)"
echo "3. Reinstall diffusers"
echo ""
read -p "Press Enter to continue or Ctrl+C to cancel..."
# Uninstall problematic packages
pip uninstall -y torch torchvision torchaudio diffusers transformers accelerate
# Install PyTorch with MPS support (standard for macOS)
pip install --no-cache-dir torch torchvision torchaudio
# Reinstall diffusers stack
pip install --no-cache-dir diffusers transformers accelerate
echo ""
echo "=== IMPORTANT: Runtime Fix ==="
echo "To prevent the mutex error while using MPS, you must set these environment variables:"
echo "export KMP_DUPLICATE_LIB_OK=True"
echo "export OMP_NUM_THREADS=1"
echo ""
echo "You can run this in your terminal now:"
echo " export KMP_DUPLICATE_LIB_OK=True && export OMP_NUM_THREADS=1"
echo ""
echo "Or add them to your ~/.zshrc to make it permanent."
echo "==============================" safetensors peft
echo ""
echo "✓ Installation complete!"
echo ""
echo "Now test with:"
echo "python generate/generate_prebuilt_diffusion.py \\"
echo " --checkpoint checkpoints/probability_diffusion/prebuilt_diffusion_epoch_88_final.pt \\"
echo " --num_classes 3 --class_id 0 --num_samples 4 \\"
echo " --num_inference_steps 50 --img_size 128 \\"
echo " --output output/probability_diffusion/generated.png"