Skip to content
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
6 changes: 6 additions & 0 deletions clearvoice/clearvoice/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ def __init__(self, args):
args.use_cuda = 1
torch.cuda.set_device(free_gpu_id)
self.device = torch.device('cuda')
elif torch.cuda.device_count() > 0:
# if the free gpu is not found, but there is at least one GPU, use the first GPU
print(f"Using GPU: {torch.cuda.get_device_name(0)}")
args.use_cuda = 1
torch.cuda.set_device(0)
self.device = torch.device('cuda:0')
Comment on lines +67 to +72
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The condition elif torch.cuda.device_count() > 0: is redundant because torch.cuda.is_available() (checked at line 60) already ensures that at least one GPU is available. This addition also makes the subsequent else block (lines 73-77) unreachable dead code. Consider simplifying the logic by defaulting free_gpu_id to 0 if get_free_gpu() returns None, which would allow removing the redundant branches and improving maintainability.

else:
# If no GPU is detected, use the CPU
#print("No GPU found. Using CPU.")
Expand Down

This file was deleted.

This file was deleted.

Loading