'str' object has no attribute 'to'

Error while loading waveglow model

waveglow_path = '/home/ec2-user/SageMaker/waveglow'
waveglow = torch.load(waveglow_path)
#waveglow.load_state_dict(torch.load(waveglow_path))
waveglow = waveglow_path.to('cuda')
waveglow.eval()
#waveglow.cpu().eval()

You are trying to push the waveglow_path to the device, which is just the string defining the PATH to a directory, so replace it with waveglow.to('cuda').

1 Like

oh yes. That was too silly of me. Well, after applying the changes Iā€™m getting this error.

'dict' object has no attribute 'to'

torch.load(waveglow_path) seems to load a state_dict, so you would need to create the model instance and load this state_dict afterwards.

model = WaveGlow() # or whatever class name is used for the actual model
state_dict = torch.load(waveglow_path)
model.load_state_dict(state_dict)