我想在mps设备上运行零射击分类任务的管道摘要。这是我的密码
pipe = pipeline('zero-shot-classification', device = mps_device)
seq = "i love watching the office show"
labels = ['negative', 'positive']
pipe(seq, labels)
生成的错误是
RuntimeError: Placeholder storage has not been allocated on MPS device!
我猜是因为seq在我的cpu上而不是mps上。我怎么才能解决这个问题?是否有方法将seq发送到mps设备,以便我可以将其传递到管道进行推断?
谢谢
发布于 2022-09-28 10:06:47
当我遇到类似的问题时,通过执行model = model.to("mps")
就可以解决这个问题,尽管在您的情况下不应该是一个问题。
以下代码在我的机器上工作:
import os
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
from transformers import pipeline
mps_device = "mps"
pipe = pipeline('zero-shot-classification', device = mps_device)
seq = "i love watching the office show"
labels = ['negative', 'positive']
pipe(seq, labels)
https://stackoverflow.com/questions/72861962
复制相似问题