一问难求 2022-01-20 14:11 采纳率: 60%
浏览 3520
已结题

IndexError: Caught IndexError in DataLoader worker process 0.

问题遇到的现象和发生背景

ssd跑自制数据集显示:
IndexError: Caught IndexError in DataLoader worker process 0.

问题相关代码,请勿粘贴截图
 def reraise(self):
    r"""Reraises the wrapped exception in the current thread"""
    # Format a message such as: "Caught ValueError in DataLoader worker
    # process 2. Original Traceback:", followed by the traceback.
    msg = "Caught {} {}.\nOriginal {}".format(
        self.exc_type.__name__, self.where, self.exc_msg)
    if self.exc_type == KeyError:
        # KeyError calls repr() on its argument (usually a dict key). This
        # makes stack traces unreadable. It will not be changed in Python
        # (https://bugs.python.org/issue2651), so we work around it.
        msg = KeyErrorMessage(msg)
    elif getattr(self.exc_type, "message", None):
        # Some exceptions have first argument as non-str but explicitly
        # have message field
        raise self.exc_type(message=msg)
    raise self.exc_type(msg)
运行结果及报错内容

File "C:\Users\huayuan001.conda\envs\pyqxr\lib\site-packages\torch\utils\data\dataloader.py", line 1225, in _process_data
data.reraise()
File "C:\Users\huayuan001.conda\envs\pyqxr\lib\site-packages\torch_utils.py", line 429, in reraise
raise self.exc_type(msg)
IndexError: Caught IndexError in DataLoader worker process 0.

我的解答思路和尝试过的方法

将num_workers设置为0。
parser.add_argument('--num_workers', default=0, type=int,
help='Number of workers used in dataloading')

我想要达到的结果

解决DataLoader进程问题

  • 写回答

1条回答 默认 最新

  • BryceRui 2022-01-20 14:24
    关注

    你这个应该是数据的问题,不是进程的问题,你把数据和标签打印下来看看。打印数据的shape和标签的shape

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 1月20日
  • 创建了问题 1月20日

悬赏问题

  • ¥15 封装的 matplotlib animation 不显示图像
  • ¥15 python摄像头画面无法显示
  • ¥15 关于#3d#的问题:d标定算法(语言-python)
  • ¥15 cve,cnnvd漏洞扫描工具推荐
  • ¥15 图像超分real-esrgan网络自己训练模型遇到问题
  • ¥15 如何构建全国统一的物流管理平台?
  • ¥100 ijkplayer使用AndroidStudio/CMake编译,如何支持 rtsp 直播流?
  • ¥15 用js遍历数据并对非空元素添加css样式
  • ¥15 使用autodl云训练,希望有直接运行的代码(关键词-数据集)
  • ¥50 python写segy数据出错