PyTorch RuntimeError:DataLoader 工作线程(pid(s) 15332)意外退出

2023-12-25

我是 PyTorch 的初学者,我只是尝试一些示例在这个网页上 https://github.com/pytorch/examples/。但由于此错误,我似乎无法运行“super_resolution”程序:

RuntimeError: DataLoader worker (pid(s) 15332) exited unexpectedly

网上搜了一下,发现有人建议设置num_workers to 0。但如果我这样做,程序会告诉我内存不足(无论是 CPU 还是 GPU):

RuntimeError: [enforce fail at ..\c10\core\CPUAllocator.cpp:72] data. DefaultCPUAllocator: not enough memory: you tried to allocate 9663676416 bytes. Buy new RAM!

or

RuntimeError: CUDA out of memory. Tried to allocate 1024.00 MiB (GPU 0; 4.00 GiB total capacity; 2.03 GiB already allocated; 0 bytes free; 2.03 GiB reserved in total by PyTorch)

我该如何解决?


我在Win10(64位)和pytorch 1.4.0上使用python 3.8。


更完整的错误消息(--cuda意味着使用GPU,--threads x意味着通过x to the num_worker范围):

  1. 使用命令行参数--upscale_factor 1 --cuda
  File "E:\Python38\lib\site-packages\torch\utils\data\dataloader.py", line 761, in _try_get_data
    data = self._data_queue.get(timeout=timeout)
  File "E:\Python38\lib\multiprocessing\queues.py", line 108, in get
    raise Empty
_queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Z:\super_resolution\main.py", line 81, in <module>
    train(epoch)
  File "Z:\super_resolution\main.py", line 48, in train
    for iteration, batch in enumerate(training_data_loader, 1):
  File "E:\Python38\lib\site-packages\torch\utils\data\dataloader.py", line 345, in __next__
    data = self._next_data()
  File "E:\Python38\lib\site-packages\torch\utils\data\dataloader.py", line 841, in _next_data
    idx, data = self._get_data()
  File "E:\Python38\lib\site-packages\torch\utils\data\dataloader.py", line 808, in _get_data
    success, data = self._try_get_data()
  File "E:\Python38\lib\site-packages\torch\utils\data\dataloader.py", line 774, in _try_get_data
    raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str))
RuntimeError: DataLoader worker (pid(s) 16596, 9376, 12756, 9844) exited unexpectedly
  1. 使用命令行参数--upscale_factor 1 --cuda --threads 0
  File "Z:\super_resolution\main.py", line 81, in <module>
    train(epoch)
  File "Z:\super_resolution\main.py", line 52, in train
    loss = criterion(model(input), target)
  File "E:\Python38\lib\site-packages\torch\nn\modules\module.py", line 532, in __call__
    result = self.forward(*input, **kwargs)
  File "Z:\super_resolution\model.py", line 21, in forward
    x = self.relu(self.conv2(x))
  File "E:\Python38\lib\site-packages\torch\nn\modules\module.py", line 532, in __call__
    result = self.forward(*input, **kwargs)
  File "E:\Python38\lib\site-packages\torch\nn\modules\conv.py", line 345, in forward
    return self.conv2d_forward(input, self.weight)
  File "E:\Python38\lib\site-packages\torch\nn\modules\conv.py", line 341, in conv2d_forward
    return F.conv2d(input, weight, self.bias, self.stride,
RuntimeError: CUDA out of memory. Tried to allocate 1024.00 MiB (GPU 0; 4.00 GiB total capacity; 2.03 GiB already allocated; 954.35 MiB free; 2.03 GiB reserved in total by PyTorch)

这是对我有用的解决方案。它可能适用于其他 Windows 用户。 只需删除/评论num workers禁用并行负载

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

PyTorch RuntimeError:DataLoader 工作线程(pid(s) 15332)意外退出 的相关文章

随机推荐

  • 如何检查 DateTime 对象是否未分配?

    所以 首先 代码 我有一堂课 public class Myobject public string Code get set public DateTime StartDate get set 这是非常简单的来源的一部分 MyObject
  • Zend Soap 自动发现和生成的 WSDL 中的 nillable="true"

    我在用着Zend Soap 自动发现 http framework zend com manual en zend soap autodiscovery html为我的 Web 服务器生成 WSDL 文件 问题是每个复杂类型的每个元素都默认
  • 如果用户将焦点设置在文本字段上,则显示屏幕键盘。具有 .Net 4 客户端配置文件的 WPF

    对于我的全屏 WPF 应用程序 如果用户将焦点设置在文本字段上 我需要显示 Windows 7 屏幕键盘 该面板没有硬键盘 只有一个与之交互的鼠标设备 在这种情况下 我需要一个屏幕键盘来填充文本字段 WPF 应用程序是在 Net Frame
  • 从 ExtJS 3.0 迁移到 4.0

    之前在 ext 3 0 中 我们使用 XML 响应构建了树面板 为此 我们有自定义类扩展 Ext tree TreeLoader 这个 TreeLoader 对于构建树结构 父 子节点 很有用 迁移到 4 0 时发现 TreeLoader
  • 组合多个高级 mysql select 查询的最佳方式

    我有来自同一数据库上不同表的多个选择语句 我使用多个单独的查询 然后加载到我的数组并排序 同样 在查询中排序后 我想合并到一个语句中以加快结果速度并使其更容易 加载更多 见底部 每个查询使用 SELECT LEFT JOIN WHERE 和
  • 程序运行 Pika 抛出 AMQPConnectionError

    浏览此处的 Rabbit MQ Pika HelloWorld 教程 https www rabbitmq com tutorials tutorial one python html https www rabbitmq com tuto
  • Python:获取 2010 年 7 月最后一个星期一

    如何获取给定月份的最后一个星期一 或其他日期 看一下dateutil http labix org python dateutil from datetime import datetime from dateutil import rel
  • 在 AngularJS 应用程序中运行 Karma 单元测试时出现“意外请求”错误

    我正在尝试为控制器编写一个单元测试 该控制器使用 http 服务获取文章详细信息 控制器 controller ArticleDetailCtrl function scope Article routeParams API URL ART
  • Python:如果在 try 或 if 中定义变量仍然可以访问? [复制]

    这个问题在这里已经有答案了 我是 Python 初学者 有 C C 背景 我正在使用Python 2 7 我读了这篇文章 Python 命名空间 范围解析和 LEGB 规则的初学者指南 http spartanideas msu edu 2
  • 继续断言

    Assert后有办法继续测试吗 我需要查看断言引起的所有情况 foreach var ex in data Assert AreEqual ex1 ex msg 不 你不能 Assert如果失败就会抛出异常 并且你不能在异常之后继续执行 你
  • 无法绑定地址 [0]:php 错误

    无法绑定地址 0 通常只允许每个套接字地址 协议 网络地址 端口 使用一次 错误是由我的 php 服务器页面给出的 我尝试了不同的端口号 如从 cmd 中查看和编写 netstat an 我也在谷歌上搜索但没有解决方案 我正在使用 wamp
  • 如何在 Swift 中捕获异常

    我知道并理解 swift 中的错误处理 没有例外 但在 Cocoa 和 Cocoa Touch 中 有些情况除了捕获异常之外没有其他方法可以处理错误 例如 如果您在可用空间不足时写入文件句柄 这不是我们希望应用程序崩溃的情况 如何处理这种情
  • 二阶颂歌系统的庞加莱截面

    这是我第一次尝试用 Python 编写庞加莱节代码 我从这里借用了一段代码 https github com williamgilpin rk4 blob master rk4 demo py https github com willia
  • Facebook API SDK 撤销访问权限

    如何允许用户使用其 API 服务 SDK 撤销对我的应用程序的访问权限 http developers facebook com docs sdks http developers facebook com docs sdks 查看文档 我
  • 如何在 C++ 中发送或保存函数以及接收或恢复函数并执行它?

    有什么方法可以将函数发送或保存为文件吗 我想在 Windows 平台上用 C 执行此操作 我假设读者和发件人或保存者之间存在某种约定 如果我像下面这样发送可以吗 服务器端 label1 int func1 int somevar int a
  • AngularJS:从列表动态添加组件

    因此 我正在开发一个允许用户修改模板的项目 基本模板将由组件组成 用户将能够添加或删除组件 我在网上找到了一些东西 例如grapeJS 但对于这个简单的应用程序来说 它的强度还远远不够 寻找一些有关解决此问题的方法的建议 或任何有帮助的资源
  • 为什么 django 网站上的日志功能不起作用?

    这就是我尝试过的 在我的 view py 文件中 import logging logger logging getLogger mylog logging basicConfig format name s levelname s mes
  • Dart - Base64 字符串不等于 python

    当我使用Python生成一个base64将在中使用的字符串raw key raw value GMAIL API 发送电子邮件完美发生 但是当我使用 Dart 生成相同的base64string 该字符串与 python 不同 因此我无法发
  • 如何使 Orientdb 的优势变得独特

    如何使 Edge 在 Orientdb 中独一无二 我想出的解决方案 删除边缘 再次创建它 但这并不好 Edge 没有任何属性 Example create edge is friend from 12 0 to 12 3 如果我再次调用它
  • PyTorch RuntimeError:DataLoader 工作线程(pid(s) 15332)意外退出

    我是 PyTorch 的初学者 我只是尝试一些示例在这个网页上 https github com pytorch examples 但由于此错误 我似乎无法运行 super resolution 程序 RuntimeError DataLo