pytoch dataloader can only join a child process

Nov. 24, 2019, 10:22 p.m.

read: 2563

环境

python版本3.7.0
pytorch版本1.3.1
pycharm远程调试

import torch
from torch import multiprocessing

# DEPENDANCY: This is required for ``DistributedDataParallel``
# https://pytorch.org/docs/stable/nn.html?highlight=distributeddataparallel#torch.nn.parallel.DistributedDataParallel
try:
    multiprocessing.set_start_method('spawn')
except RuntimeError:
    pass

# DEPENDANCY: This is required for ``from tqdm import tqdm``
# https://github.com/tqdm/tqdm/blob/96d8a3c3642474144f53f74331ef2172d1c39496/tqdm/_tqdm.py#L74
mp_lock = multiprocessing.RLock()

import torch
from torch.utils.data import DataLoader

if __name__ == '__main__':
    data_iterator = torch.utils.data.DataLoader([torch.tensor(i) for i in range(10)], num_workers=4)
    for batch in data_iterator:
        pass

直接运行以上简单代码会报错
解决方案/solution
重启pycharm/restart pycharm
如果以上方法行不通 / or
step 1.切换到python3.6环境 / change python version to python3.6
step 2.切换到pytorch 1.1.0/ change pytorch version to 1.1.0




Bye2019,Hello2020

今天是2020年元旦,阳历新年的第一天。又到了该更新一篇博客的时间了,链接一下去年今日的博客Hello 2019。毕竟是阳历新年的第一天,这个博客的主题应该是温故而知新?不不不应该是回顾过去的一年,…

SoX 变速不变调 音频加速减速

文章标题:SoX 变速不变调 音频加速减速 文章内容: SoX - 音频处理的瑞士军刀Welcome to the home of SoX, the Swiss Army knife of soun…

此站点由 ASP.NETIIS 驱动 | © 2018-2023 hupeng.me. All Rights Reserved.