我有一个export.pkl
在 cuda 机器上训练过的模型。我想在 macbook 上使用它:
from fastai.text import load_learner
from utils import get_corpus
learner = load_learner('./models')
corpus = get_corpus()
res = [ str(learner.predict(c)[0]) for c in corpus ]
我收到以下错误:
...
File "/Users/gautiergilabert/Envs/cc/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 146, in forward
"them on device: {}".format(self.src_device_obj, t.device))
RuntimeError: module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: cpu
我有两个问题:
- 我
raise
在我的export.pkl
:
for t in chain(self.module.parameters(), self.module.buffers()):
if t.device != self.src_device_obj:
raise RuntimeError("module must have its parameters and buffers "
"on device {} (device_ids[0]) but found one of "
"them on device: {}".format(self.src_device_obj, t.device))
据说关于文档字符串中的模块:module to be parallelized
. 我真的不明白它是什么。我的笔记本电脑?
除了我的macbook,我想在cpu上运行模型
- 有没有办法让这个
export.pkl
模型在 cpu 上工作? - 有没有办法
export.pkl
在 cuda 上制作另一个并在 cpu 上可用?
谢谢