Tacotron2: inference on cpu

Created on 27 Jun 2019  路  1Comment  路  Source: NVIDIA/tacotron2

What changes do we need to make if we want to infer our model on CPU?

in speech(t)
5 sequence = torch.autograd.Variable(
6 torch.from_numpy(sequence)).cuda().long() #originally torch.from_numpy(sequence)).cuda().long()
----> 7 mel_outputs, mel_outputs_postnet, _, alignments = model.inference(sequence)
8 with torch.no_grad():
9 audio = waveglow.infer(mel_outputs_postnet, sigma=0.666)

~/tacotron2/model.py in inference(self, inputs)
516
517 def inference(self, inputs):
--> 518 embedded_inputs = self.embedding(inputs).transpose(1, 2)
519 encoder_outputs = self.encoder.inference(embedded_inputs)
520 mel_outputs, gate_outputs, alignments = self.decoder.inference(

~/anaconda3/envs/tts/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, input, *kwargs)
491 result = self._slow_forward(input, *kwargs)
492 else:
--> 493 result = self.forward(input, *kwargs)
494 for hook in self._forward_hooks.values():
495 hook_result = hook(self, input, result)

~/anaconda3/envs/tts/lib/python3.6/site-packages/torch/nn/modules/sparse.py in forward(self, input)
115 return F.embedding(
116 input, self.weight, self.padding_idx, self.max_norm,
--> 117 self.norm_type, self.scale_grad_by_freq, self.sparse)
118
119 def extra_repr(self):

~/anaconda3/envs/tts/lib/python3.6/site-packages/torch/nn/functional.py in embedding(input, weight, padding_idx, max_norm, norm_type, scale_grad_by_freq, sparse)
1504 # remove once script supports set_grad_enabled
1505 _no_grad_embedding_renorm_(weight, input, max_norm, norm_type)
-> 1506 return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
1507
1508

RuntimeError: Expected object of backend CPU but got backend CUDA for argument #3 'index'

Most helpful comment

You have to change all instances of .cuda() to .cpu()

>All comments

You have to change all instances of .cuda() to .cpu()

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xDuck picture xDuck  路  4Comments

Mr-DDDAlKilanny picture Mr-DDDAlKilanny  路  3Comments

deadskull7 picture deadskull7  路  5Comments

geneing picture geneing  路  4Comments

Jiff-Zhang picture Jiff-Zhang  路  7Comments