Skip to content

Commit

Permalink
'v0.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
CNChTu committed Dec 16, 2023
1 parent 415ac32 commit 3e2bf2b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
setup(
name='torchfcpe',
description='The official Pytorch implementation of Fast Context-based Pitch Estimation (FCPE)',
version='0.0.1',
version='0.0.2',
author='CNChTu',
author_email='[email protected]',
url='https://github.com/CNChTu/FCPE',
Expand Down
21 changes: 14 additions & 7 deletions torchfcpe/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,19 +352,26 @@ def get_device(device: str, func_name: str) -> str:
"""Get device"""

if device is None:
device = 'cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu'
if torch.cuda.is_available():
device = 'cuda'
elif torch.backends.mps.is_available():
device = 'mps'
else:
device = 'cpu'

print(f' [INFO]: Using {device} automatically.')
print(f' [INFO] > call by: {func_name}')

# Check if the specified device is available, if not, switch to cpu
if device == 'cuda' and not torch.cuda.is_available() or device == 'mps' and not torch.backends.mps.is_available():
print(f' [WARNING]: Specified device ({device}) is not available, switching to cpu.')
device = 'cpu'

else:
print(f' [INFO]: device is not None, use {device}')
print(f' [INFO] > call by:{func_name}')
device = device

# Check if the specified device is available, if not, switch to cpu
if ((device == 'cuda' and not torch.cuda.is_available()) or
(device == 'mps' and not torch.backends.mps.is_available())):
print(f' [WARN]: Specified device ({device}) is not available, switching to cpu.')
device = 'cpu'

return device


Expand Down

0 comments on commit 3e2bf2b

Please sign in to comment.