Skip to content

Commit

Permalink
Fixed hardware acceleration detection to not throw error on CUDA env,…
Browse files Browse the repository at this point in the history
… improved README
  • Loading branch information
beveradb committed Dec 21, 2023
1 parent f1c3ee7 commit 91e954a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 2 additions & 9 deletions audio_separator/separator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand All @@ -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"]

Expand Down

0 comments on commit 91e954a

Please sign in to comment.