I am trying to run the basic fine-tuning a pretrained model code from the huggingface page (Fine-tune a pretrained model) and am getting a runtime error:
RuntimeError: Placeholder storage has not been allocated on MPS device!
I know this is something to do with the device Pytorch is running on but I have no idea how to solve it.
This worked for me, too. I was finishing the tutorial series to work out the development environment for tomorrow’s work and hit that MPS issue. @pmoraes solution solved it.
Context:
Apple M1 MBP
PyTorch in a conda (MiniForge3) environment
It took nearly 9 minutes over three epochs, and I used the small training and test datasets. The eval loss dropped each epoch, and accuracy increased. It worked.
I have some understanding of editing code but not a programmer ( so please tell us where to paste the code a) which file - which directory etc - or is it a command via terminal?
The error appears when trying to generate an image from lineart __ ( ControlNet ) on a pertained model -
Mac: RuntimeError: Placeholder storage has not been allocated on MPS device __
Please explain in lamen terms - what piece of code needs to be replaced and where. I’ve seen other posts but they all relate to M1 Macs. If this issue has been resolved elsewhere for an Intel based Mac please share the link.
Can someone please do a YouTube video on this? I’m using Pinokio controllnet is saying the same thing. “placeholder storage has not been allocated on mps device!”
believe it has something to do with how Trainer handles the models and tensors
Because my model reverts back to cpu after initialising the Trainer class though being preded by model.to(torch.device(“mps”))
By passing in the the no_cuda, it uses cpu in all scenarios & avoids the mps saga
it’s a bug,
line 2157 training_args.py device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu" )
it changed to CPU even though it was mps
Thank you that solved the issue for me, and enabled me to train using the apple sillicone GPU by changing the last part of the line to “mps” (instead of “cpu”)