Fine tuning a pre-trained model using GPU

I am trying to fine tune a pre-trained model using a GPU but I cant find a way to move the model to GPU. I have followed the tutorial on fine-tuning but I havent seen how the model is moved to GPU. I moved the input to GPU and tried training the model but I got the following error as expected : “RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same”.

On the Google Colab, we are not using YAML (hard to handle yaml file properly in Colab). The best way is simply to create a proper YAML file for your experiment, and putting your model in a modules variable that is passed to the brain class. It will then be properly sent to the device. Of course you need to do device=‘cuda’ on the hparams.

I am using “separator.from_hparams(…)” to load the pretrained model. I dowloand the hyperparameters.yaml file when downloading the model. I tried adding device='cuda' to the hparams file but i get an error, what part of the hparams file should I add the device='cuda' statement?

Without a proper view on your entire code, it is quite hard to help :confused: Could you provide us the code ? I am not sure to understand the use case for now.

I solved the problem by following someone elses post on github, basically I just set run_opts={‘device’:'cude:} for the brain class. Thanks.

1 Like

Could you share the post that helped solve your problem?