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

Mps support #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion noisereduce/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
from noisereduce.noisereduce import reduce_noise
import os
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"

from noisereduce.noisereduce import reduce_noise
2 changes: 1 addition & 1 deletion noisereduce/spectralgate/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def _read_chunk(self, i1, i2):
i2b = self.n_frames
else:
i2b = i2
chunk = np.zeros((self.n_channels, i2 - i1))
chunk = np.zeros((self.n_channels, i2 - i1), dtype=self._dtype)
chunk[:, i1b - i1: i2b - i1] = self.y[:, i1b:i2b]
return chunk

Expand Down
6 changes: 5 additions & 1 deletion noisereduce/spectralgate/streamed_torch_gate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import torch
from noisereduce.spectralgate.base import SpectralGate
from noisereduce.torchgate import TorchGate as TG
Expand Down Expand Up @@ -50,7 +51,10 @@ def __init__(
n_jobs=n_jobs,
)

self.device = torch.device(device if torch.cuda.is_available() else 'cpu')
if "cuda" in device and not torch.cuda.is_available():
device = "cpu"

self.device = torch.device(device)

# noise convert to torch if needed
if y_noise is not None:
Expand Down