From 91e954a660a82ee43b49ecdd82c627e3136ad47c Mon Sep 17 00:00:00 2001 From: Andrew Beveridge Date: Thu, 21 Dec 2023 14:45:16 -0600 Subject: [PATCH] Fixed hardware acceleration detection to not throw error on CUDA env, improved README --- README.md | 24 ++++++++++++------------ audio_separator/separator.py | 11 ++--------- pyproject.toml | 5 +++-- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 4764117..1f21202 100644 --- a/README.md +++ b/README.md @@ -18,24 +18,24 @@ The primary stem typically contains the instrumental part of the audio, while th ## Installation 🛠️ -You can install Audio Separator using pip, use one of the following depending on your device: +You'll need `ffmpeg` and `libsndfile`, which should be easy to install on most platforms, e.g.: -Nvidia GPU with CUDA support: -`pip install audio-separator[gpu]` +- Debian/Ubuntu: `apt-get update; apt-get install -y libsndfile1-dev ffmpeg` +- macOS: `brew update; brew install libsndfile ffmpeg` -Apple Silicon running macOS Sonoma+ with CoreML support: -`pip install audio-separator[silicon]` +You can then install Audio Separator using pip, use one of the following to install the correct onnxruntime dependency for your device: + +### Nvidia GPU with CUDA acceleration: -No specific hardware acceleration, CPU only, slow -`pip install audio-separator` +`pip install audio-separator[gpu]` -### Requirements +### Apple Silicon, macOS Sonoma+ with CoreML acceleration: -You'll need two other things installed on your system: `ffmpeg` and `libsndfile`. -These should be easy to install on most platforms, e.g. +`pip install audio-separator[silicon]` -- Debian/Ubuntu: `apt-get update; apt-get install -y libsndfile1-dev ffmpeg` -- macOS: `brew update; brew install libsndfile ffmpeg` +### No hardware acceleration, CPU only: + +`pip install audio-separator[cpu]` ### GPU / CUDA specific steps diff --git a/audio_separator/separator.py b/audio_separator/separator.py index 9c9f664..ef9e28d 100644 --- a/audio_separator/separator.py +++ b/audio_separator/separator.py @@ -124,12 +124,7 @@ def __init__( self.logger.warning("CUDAExecutionProvider not available in ONNXruntime, so acceleration will NOT be enabled") self.logger.warning("If you expect CUDA to work with your GPU, try pip install --force-reinstall onnxruntime-gpu") else: - self.logger.debug( - "CUDA not available with Torch installation. If you have an Nvidia GPU and expect CUDA support to work, try: " - ) - self.logger.debug( - "pip install --force-reinstall torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118" - ) + self.logger.debug("CUDA not available in Torch installation. If you expect GPU/CUDA support to work, please see README") if hasattr(torch.backends, "mps") and torch.backends.mps.is_available(): self.logger.info("Apple Silicon MPS/CoreML is available in Torch, setting Torch device to MPS") @@ -149,9 +144,7 @@ def __init__( self.logger.warning("CoreMLExecutionProvider not available in ONNXruntime, so acceleration will NOT be enabled") self.logger.warning("If you expect MPS/CoreML to work with your Mac, try pip install --force-reinstall onnxruntime-silicon") else: - raise Exception( - "Apple Silicon CoreML / MPS requested but not available with current Torch installation. Do you have an Apple Silicon GPU?" - ) + self.logger.debug("Apple Silicon MPS/CoreML not available in Torch installation. If you expect this to work, please see README") if not hardware_acceleration_enabled: self.logger.info("No hardware acceleration could be configured, running in CPU mode") diff --git a/pyproject.toml b/pyproject.toml index a294da9..4d5e1f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "audio-separator" -version = "0.9.0" +version = "0.9.1" description = "Easy to use vocal separation on CLI or as a python package, using the amazing MDX-Net models from UVR trained by @Anjok07" authors = ["Andrew Beveridge "] license = "MIT" @@ -19,11 +19,12 @@ librosa = ">=0.9" torch = ">=2" wget = ">=3" six = ">=1.16" -onnxruntime = ">=1.15" +onnxruntime = { version = ">=1.15", optional = true } onnxruntime-gpu = { version = ">=1.15", optional = true } onnxruntime-silicon = { version = ">=1.15", optional = true } [tool.poetry.extras] +cpu = ["onnxruntime"] gpu = ["onnxruntime-gpu"] silicon = ["onnxruntime-silicon"]