Skip to content

Commit

Permalink
Improved hardware acceleration readme steps
Browse files Browse the repository at this point in the history
  • Loading branch information
beveradb committed Dec 21, 2023
1 parent 91e954a commit e334bd6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 21 deletions.
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,51 @@ The primary stem typically contains the instrumental part of the audio, while th

You'll need `ffmpeg` and `libsndfile`, which should be easy to install on most platforms, e.g.:

- Debian/Ubuntu: `apt-get update; apt-get install -y libsndfile1-dev ffmpeg`
- macOS: `brew update; brew install libsndfile ffmpeg`
### 🐧 Debian/Ubuntu
`apt-get update; apt-get install -y libsndfile1-dev ffmpeg`

###  macOS
`brew update; brew install libsndfile ffmpeg`

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:
### 🎮 Nvidia GPU with CUDA acceleration

`pip install audio-separator[gpu]`

### Apple Silicon, macOS Sonoma+ with CoreML acceleration:
- 💬 If successfully configured, you should see this log message when running audio-separator:
`ONNXruntime has CUDAExecutionProvider available, enabling acceleration`

###  Apple Silicon, macOS Sonoma+ with CoreML acceleration

`pip install audio-separator[silicon]`

### No hardware acceleration, CPU only:
- 💬 If successfully configured, you should see this log message when running audio-separator:
`ONNXruntime has CoreMLExecutionProvider available, enabling acceleration`

### 🐢 No hardware acceleration, CPU only:

`pip install audio-separator[cpu]`


### GPU / CUDA specific steps
## GPU / CUDA specific installation steps

In theory, all you should need to do to get `audio-separator` working with a GPU is install it with the `[gpu]` extra as above.

However, sometimes getting both PyTorch and ONNX Runtime working with CUDA support can be a bit tricky so sometimes it may not be that easy.
However, sometimes getting both PyTorch and ONNX Runtime working with CUDA support can be a bit tricky so it may not work that easily.

You may need to reinstall them directly, allowing pip to calculate the right versions for your platform:
You may need to reinstall both packages directly, allowing pip to calculate the right versions for your platform:

- `pip uninstall torch onnxruntime`
- `pip cache purge`
- `pip install torch torchvision torchaudio`
- `pip install onnxruntime-gpu`
- `pip install --force-reinstall torch torchvision torchaudio`
- `pip install --force-reinstall onnxruntime-gpu`

Depending on your hardware, you may get better performance with the optimum version of onnxruntime:
- `pip install "optimum[onnxruntime-gpu]"`
- `pip install --force-reinstall "optimum[onnxruntime-gpu]"`

Depending on your CUDA version and hardware, you may need to install torch from the `cu118` index instead:
- `pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118`
- `pip install --force-reinstall torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118`

> Note: if anyone knows how to make this cleaner so we can support both different platform-specific dependencies for hardware acceleration without a separate installation process for each, please let me know or raise a PR!
Expand Down
2 changes: 1 addition & 1 deletion audio_separator/separator.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __init__(
self.device = torch.device("cuda")

if ort_device == "GPU" and "CUDAExecutionProvider" in ort_providers:
self.logger.info("ONNXruntime device is GPU with CUDAExecutionProvider available, enabling acceleration")
self.logger.info("ONNXruntime has CUDAExecutionProvider available, enabling acceleration")
self.onnx_execution_provider = ["CUDAExecutionProvider"]
hardware_acceleration_enabled = True
else:
Expand Down
4 changes: 3 additions & 1 deletion audio_separator/utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import argparse
import logging
import pkg_resources
from audio_separator import Separator


def main():
Expand Down Expand Up @@ -83,6 +82,9 @@ def main():

logger.info(f"Separator beginning with input file: {args.audio_file}")

# Deliberately import here to avoid loading heave dependencies when just running --help
from audio_separator import Separator

separator = Separator(
args.audio_file,
log_formatter=log_formatter,
Expand Down
13 changes: 7 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "audio-separator"
version = "0.9.1"
version = "0.9.2"
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 Down

0 comments on commit e334bd6

Please sign in to comment.