CPU infrence on GPU trained model

(Ayush Saklani) #1

I was trying to run inference on GPU trained model on my laptop, But, I am receiving error and model is not loading.

learn = load_learner(‘models’,cpu=True)
File “/home/zero/Softwares/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/basic_train.py”, line 574, in load_learner
state = torch.load(Path(path)/fname, map_location=‘cpu’) if defaults.device == torch.device(‘cpu’) else torch.load(Path(path)/fname)
File “/home/zero/Softwares/anaconda3/envs/fastai/lib/python3.7/site-packages/torch/serialization.py”, line 368, in load
return _load(f, map_location, pickle_module)
File “/home/zero/Softwares/anaconda3/envs/fastai/lib/python3.7/site-packages/torch/serialization.py”, line 542, in _load
result = unpickler.load()
AttributeError: Can’t get attribute ‘ImageItemList’ on <module ‘fastai.vision.data’ from ‘/home/zero/Softwares/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/vision/data.py’>

How can i load the model on CPU.

(Dominik Engel) #2

Do you have the same versions of fastai on both machines?
fastai.vision.data.ImageItemList was recently renamed to ImageList. Maybe two different versions are causing your problems here.