-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Support MPS for macOS #124
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
base: main
Are you sure you want to change the base?
Conversation
|
Checked on Generation of an example is successful |
|
works well on mac m3 pro |
|
Attempting to run this on M4 Max with the instructions above (same instructions on the README from the PR repo), I consistently fail when trying to generate using gradio (pytohn3 app.py --device mps) with |
|
It took me a while to figure out, but the Python venv setup for the project installs Pytorch 2.6.0.
to upgrade to the latest version 2.7.0. After that, I was able to successfully run/validate the code |
|
참고로, 이번 작업을 수행한 과정을 기록한 블로그 글입니다. |
Considering that you already have a conditional setup in the poetry config file, it would be a good idea for you to install torch 2.7.0 if you're on macos instead of the current 2.6 config. This would prevent the issues that I and others in the 2 discussion threads that exist with people reporting that this PR did not work for them |
Specifically for any one who is trying to replicate this, you have to clone @devnoff mac branch: git clone --single-branch --branch mac https://github.com/devnoff/dia.git Follow the rest of the instructions (personally I use the exact python version 3.10.16 for the venv/conda env). Works great. @devnoff 정말 감사합니다. 훌륭해요 Vibe Coding! |
|
Device: Apple M3 Pro, 36GB, macOS sonoma It seems to work, I see GPU usage going up (80-95%). But eventually failed with this error: |




요약 (Summary)
이 PR은 Dia 모델을 macOS 환경 (Apple Silicon 및 Intel)에서 실행할 수 있도록 지원을 추가합니다. Apple Silicon의 Metal Performance Shaders (MPS)를 활용한 GPU 가속과 CPU 폴백(fallback) 실행을 모두 지원합니다.
동기 (Motivation)
기존 코드는 주로 CUDA 환경을 기준으로 테스트 및 설정되어 있어 macOS 사용자가 로컬 환경에서 모델을 사용하기 어려웠습니다. 이 변경을 통해 macOS 사용자, 특히 Apple Silicon 칩을 사용하는 사용자들이 모델을 더 쉽게 활용할 수 있게 됩니다.
변경 내용 (Changes Made)
descript-audio-codec라이브러리와의 호환성 문제가 발견되어 Python 3.10을 필수 요구사항으로 지정했습니다. (.python-version파일은 있으나,pyenv사용은 사용자의 선택사항입니다.)app.py,cli.py,dia/model.py,dia/state.py등 관련 파일에서 CUDA 외에 MPS (torch.backends.mps.is_available()) 및 CPU 장치를 감지하고 사용하도록 로직을 수정했습니다.app.py)과 CLI (cli.py)에서--device mps또는--device cpu인자를 통해 실행 장치를 명시적으로 선택할 수 있도록 지원합니다.cli.py의 시드 설정 로직(set_seed)이 현재 활성화된 장치(CUDA, MPS, CPU)를 인식하도록 수정했습니다.DiaConfig,DataConfig등) 초기화 및config.json파싱 관련TypeError및AttributeError해결. (log6.txt참고)descript-audio-codec(DAC) 모델 로딩 방식 수정 (dac.DAC.load()사용).DiaModel초기화 시 dtype 처리 방식 수정.DiaModel,Encoder,Decoder등)에 올바른 설정 객체(DiaConfig)가 전달되도록 수정.README.md파일의 "Quickstart" 및 "Hardware and Inference Speed" 섹션을 업데이트하여 다음 내용을 추가/수정했습니다:pip및venv를 사용한 권장 설치 방법 안내.print문들을 제거했습니다.테스트 (Testing)
pip install .명령어로 의존성 설치가 정상적으로 완료됨을 확인했습니다.python3 cli.py "..." --output test_mps.wav --device mps명령 실행 시, MPS 장치를 사용하여 오류 없이 오디오 파일이 성공적으로 생성 및 저장됨을 확인했습니다.참고 (Notes)
uv를 사용한 설치는 환경 설정 문제로 인해 불안정할 수 있어, 표준pip사용을 권장하는 방향으로 문서를 수정했습니다.