1. 程式人生 > 實用技巧 >fastai v2 windows執行錯誤解決:RuntimeError: cuda runtime error (801) : operation not supported at ..\torch/csrc/generic/StorageSharing.cpp:247

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)