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)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM