fastai v2 windows运行错误解决:RuntimeError: cuda runtime error (801) : operation not supported at ..\torch/csrc/generic/StorageSharing.cpp:247

fastai v2对比v1有极大的改动,发布的版本主要在linux下运行,并经测试。

windows在运行learn.fine_tune(1)时出错:

d:\programdata\anaconda3\envs\fastai\lib\site-packages\torch\multiprocessing\reductions.py in reduce_tensor(tensor)
    238          ref_counter_offset,
    239          event_handle,
--> 240          event_sync_required) = storage._share_cuda_()
    241         tensor_offset = tensor.storage_offset()
    242         shared_cache[handle] = StorageWeakRef(storage)

RuntimeError: cuda runtime error (801) : operation not supported at ..\torch/csrc/generic/StorageSharing.cpp:247

解决办法:在ImageDataLoaders中添加:num_workers=0

dls = ImageDataLoaders.from_folder(path, train='train', valid='test', item_tfms=Resize(224), num_workers=0)

 

此外在learn.predict()、interp = Interpretation.from_learner(learn)中也会出现同样的错误,需修改fastai\learner.py,添加n_workers = 0:

    def get_preds(self, ds_idx=1, dl=None, with_input=False, with_decoded=False, with_loss=False, act=None,
                  inner=False, reorder=True, cbs=None, n_workers=defaults.cpus, **kwargs):
        n_workers = 0
        if dl is None: dl = self.dls[ds_idx].new(shuffled=False, drop_last=False, num_workers=n_workers)

 

posted @ 2020-09-11 23:11  碧水青山  阅读(5145)  评论(0编辑  收藏  举报