Open JakeRutherford opened 2 weeks ago
Hello!
I don't think I've seen this issue before, but a bit more searching makes me suggest that perhaps you have to use use_mps_device=True
in your SentenceTransformerTrainingArguments
:
from sentence_transformers import SentenceTransformer, SentenceTransformerTrainer, SentenceTransformerTrainingArguments, losses
from datasets import Dataset
model = SentenceTransformer("all-MiniLM-L6-v2")
train_dataset = Dataset.from_dict({
"anchor": ["It's nice weather outside today.", "He drove to work."],
"positive": ["It's so sunny.", "He took the car to the office."],
"negative": ["It's quite rainy, sadly.", "She walked to the store."],
})
loss = losses.TripletLoss(model=model)
args = SentenceTransformerTrainingArguments(
output_dir="test_trainer",
use_mps_device=True,
)
trainer = SentenceTransformerTrainer(
model=model,
args=args,
train_dataset=train_dataset,
loss=loss,
)
trainer.train()
Hello @tomaarsen !
Unfortunately adding use_mps_device=True
to the SentenceTransformerTrainingArguments
still gives the same error 🤔:
RuntimeError: Placeholder storage has not been allocated on MPS device!
Hmm, could you print the model.device
after it has been loaded? If it's not "mps"
, could you move the model with model.to("mps")
?
I'm able to find some threads online when searching for RuntimeError: Placeholder storage has not been allocated on MPS device!
, but I'm not quite sure which might help.
Hi, I have the same error, when I print the model.device after model loaded is "mps:0".
here is the version of package:
accelerate 0.32.1 transformers 4.42.3 sentence-transformers 3.0.1 torch 2.3.1
and I use Python 3.11.5
I am running this basic training example on an Apple M3 Pro. I am using Python 3.10, sentence-transformers 3.0.1, accelerate 0.31 and torch 2.3.1.
I am getting this error:
How can this be resolved?