fastai学习——第一个bug
生活随笔
收集整理的這篇文章主要介紹了
fastai学习——第一个bug
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
跟著視頻學習,在運行第一段測試代碼的時候出現(xiàn)問題
from fastai.vision.all import * path = untar_data(URLs.PETS)/'images'def is_cat(x): return x[0].isupper() dls = ImageDataLoaders.from_name_func(path, get_image_files(path), valid_pct=0.2, seed=42,label_func=is_cat, item_tfms=Resize(224))learn = cnn_learner(dls, resnet34, metrics=error_rate) learn.fine_tune(1)報錯
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
貌似是由于windows引起的,作者誠不欺我
百度無果后去官方論壇搜索,發(fā)現(xiàn)解決方案:
打開"./anaconda/envs/fastai/Lib/sitepackages/fastai/data/load.py"
搜索to_device
將
改為
if self.device is not None:b = to_device(b, self.device)修改后正常運行
論壇鏈接:https://forums.fast.ai/t/part1-2020-02-production-found-at-least-two-devices-cuda-0-and-cpu/87253/7
總結
以上是生活随笔為你收集整理的fastai学习——第一个bug的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python记忆式键入_Python基础
- 下一篇: 分割文本_PSENet、PANNet、D