Skip to content

Commit 3d758c1

Browse files
committed
Fix a bug causing cpu inference unavailable
1 parent d351c99 commit 3d758c1

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

modules/nsf_hifigan/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ def load_model(model_path, device='cuda'):
2323

2424
generator = Generator(h).to(device)
2525

26-
cp_dict = torch.load(model_path)
26+
if torch.cuda.is_available():
27+
cp_dict = torch.load(model_path)
28+
else:
29+
cp_dict = torch.load(model_path, map_location="cpu")
2730
generator.load_state_dict(cp_dict['generator'])
2831
generator.eval()
2932
generator.remove_weight_norm()

0 commit comments

Comments
 (0)