pytorch-deep-learning icon indicating copy to clipboard operation
pytorch-deep-learning copied to clipboard

PyTorch HuggingFace model not using GPU

Open Kashish-1426 opened this issue 2 years ago • 4 comments

This is the model code: model_pic

This is the PyTorch Dataset class code: Dataset Class

This is the Predictions code: predictions image

And this is the task manager: Task_manager

My Gpu works on the tutorials of the PyTorch from youtube, this code has been in the same environment and it still does not work. Any help would be appreciated please and thank you.

Kashish-1426 avatar Aug 07 '23 16:08 Kashish-1426

did you convert your variables and model device to cuda?did you ever used cuda in your codes?are you sure you config using pytorch from gpu corectly?

jenabesaman avatar Aug 25 '23 11:08 jenabesaman

Make sure you are always using NUM_WORKERS=0. In Windows only that value is the one that works

toxfu avatar Oct 12 '23 00:10 toxfu

Hi @Kashish-1426 ,

I've not had this issue before. I use computer vision models from Hugging Face quite often and they work excellent on the GPU.

I also use very similar code to you, e.g. model.to(device), just like in the PyTorch course.

Have you tried reaching out to anyone from Hugging Face?

mrdbourke avatar Oct 13 '23 04:10 mrdbourke

@mrdbourke I think He is not referring to the deployment in Huggingface. From what you can see in the images, he is referring to the code he wants to implement, but from what you can see he is executing it locally in Windows and in Windows NUM_WORKERS = 0 is the only value it supports. I'm almost sure that's the problem because I had the same problem.

toxfu avatar Oct 13 '23 05:10 toxfu