Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve Apple Silicon compatibility #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kesjam
Copy link

@kesjam kesjam commented Dec 31, 2024

Overview

This PR improves compatibility with Apple Silicon (M1/M2) Macs by addressing several MPS-related issues and improving stability.

Key Changes

  • Force CPU usage instead of MPS for better stability
  • Use float32 instead of bfloat16 for better compatibility
  • Enable MPS fallback for unsupported operations
  • Disable TF32 optimizations that can cause issues
  • Simplify Gradio interface configuration
  • Add better error handling and debugging options

Technical Details

  • Set PYTORCH_ENABLE_MPS_FALLBACK=1 for operations not supported by MPS
  • Modified device configuration in demo scripts to use CPU by default
  • Updated Gradio launch parameters for better stability
  • Added explicit output directory creation
  • Simplified interface configuration to reduce browser compatibility issues

Testing

  • Verified working on MacBook Pro (14-inch, 2024)
    • Apple M4 Max
    • 64GB Memory
    • macOS Sequoia 15.3 Beta (24D5034f)
  • Tested successfully in Safari browser
  • Confirmed video-to-audio generation working
  • Access via http://127.0.0.1:7863

Notes

  • This change primarily affects demo scripts and does not modify core functionality
  • Provides better out-of-box experience for Apple Silicon users
  • Maintains compatibility with other platforms

Key changes:

- Force CPU usage instead of MPS for better stability

- Use float32 instead of bfloat16 for better compatibility

- Enable MPS fallback for unsupported operations

- Disable TF32 optimizations

- Simplify Gradio interface configuration

- Add better error handling and debugging options

Technical details:

- Set PYTORCH_ENABLE_MPS_FALLBACK=1

- Modified device configuration in both demo scripts

- Updated Gradio launch parameters for better stability

- Added explicit output directory creation

Testing notes:

- Verified working on macOS with Apple Silicon

- Tested successfully in Safari browser

- Confirmed video-to-audio generation working

- Access via http://127.0.0.1:7863
@hkchengrex
Copy link
Owner

Hi, thank you for the pull request.

Several questions:

  • Why are we defaulting to CPU? CPU processing will be much much slower and therefore not desirable when CUDA/MPS are available.

Use float32 instead of bfloat16 for better compatibility

  • compatibility with what?

Updated Gradio launch parameters for better stability

  • How are the current parameters not stable? Can you provide examples?

Simplified interface configuration to reduce browser compatibility issues

  • What compatibility issues? Can you provide examples?

Comment on lines +41 to +50
try:
model: ModelConfig = all_model_cfg[args.variant]
if not model.model_path.exists():
log.info(f'Downloading model weights for {args.variant}...')
model.download_if_needed()
output_dir = Path('./output/gradio')
output_dir.mkdir(exist_ok=True, parents=True)
except Exception as e:
log.error(f'Error loading model: {e}')
raise
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

download_if_needed already checks for existing model files and additionally checks for MD5

@@ -24,7 +24,7 @@ def main():
parser = ArgumentParser()
parser.add_argument('--variant',
type=str,
default='large_44k_v2',
default='small_44k',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

large_44k_v2 is a better default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants