pytorch中使用多显卡训练以及训练时报错:expect more than 1 value per channel when training, got input size..
pytorch在训练中使用多卡:
conf.device = torch.device('cuda:0' if torch.cuda.is_available() else "cpu")
conf.device_ids = list(conf.device_ids)
self.model = torch.nn.DataParallel(self.model, device_ids=conf.device_ids)
self.model.to(conf.device)
然后在训练的命令行需要指定GPU:
export CUDA_VISIBLE_DEVICES=4,5,6,7
在pytorch内部,conf.device_ids依旧是从0开始的;
训练的时候报错:

是由于batchnorm层需要大于一个样本去计算其中的参数,网上搜索了解决方法是将dataloader的一个丢弃参数设置为true:

但是我设置后依旧会报错,然后就在train里面人为修改了一下:
如果剩下的照片为1,那么就丢掉,就可以了:

pytorch中使用多显卡训练以及训练时报错:expect more than 1 value per channel when training, got input size..的更多相关文章
- pytorch报错:ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1,512,1,1])
1.pytorch报错:ValueError: Expected more than 1 value per channel when training, got input size torch.S ...
- Vue+Typescript中在Vue上挂载axios使用时报错
Vue+Typescript中在Vue上挂载axios使用时报错 在vue项目开发过程中,为了方便在各个组件中调用axios,我们通常会在入口文件将axios挂载到vue原型身上,如下: main.t ...
- facenet pyhton3.5 训练 train_softmax.py 时报错AttributeError: 'dict' object has no attribute 'iteritems'
报错原因:在进行facenet进行train_softmax.py训练时,在一轮训练结束进行验证时,报错AttributeError: 'dict' object has no attribute ' ...
- [JavaEE] Entity中Lazy Load的属性序列化JSON时报错
The server encountered an internal error that prevented it from fulfilling this request.org.springfr ...
- Spring中的一个错误:使用Resources时报错(The annotation @Resources is disallowed for this location)
在学习Spring的过程中遇到一个错误:在使用注解@resources的时候提示:The annotation @Resources is disallowed for this location 后 ...
- IDEA中执行maven命令:mvn clean 时报错
问题描述: 完成项目中的功能后,想要git一下,就用maven命令先清除一下编译文件,紧接着系统报错 Error executing Maven. 2 problems were encountere ...
- 踩坑,vue项目中,main.js引入scss文件时报错
当我们在src目录下创建.scss文件,并在main.js中引用,运行时会报: ERROR Failed to compile with 1 errors 5:25:07 PMThis relativ ...
- 如何修改WAMP中mysql默认空密码 以及修改时报错的处理方法
WAMP安装好后,mysql密码是为空的,那么要如何修改呢?其实很简单,通过几条指令就行了,下面我就一步步来操作. 首先,通过WAMP打开mysql控制台. 提示输入密码,因为现在是空,所以直接按回车 ...
- 在Ubuntu中,用mvn打包hadoop源代码时报错,正在解决中!!!
报错信息如下: (各种配置在最后面) hadoop@administrator-virtual-machine:~/Downloads/tar/hadoop-3.0.0-alpha1-src$ mvn ...
随机推荐
- 阶段5 3.微服务项目【学成在线】_day17 用户认证 Zuul_09-前端显示当前用户-需求分析
登陆成功 应该要显示用户的信息 cookie只存了用户的身份令牌.不包含用户的信息 拿着短令牌 请求认证服务获取到jwt.然后存储到sessionStorage 1.用户请求认证服务,登录成功. 2. ...
- SortedMap和TreeMap有什么区别?
SortedMap和TreeMap有什么区别 答: TreeMap的类的源码: public class TreeMap<K,V> extends AbstractMap<K,V ...
- python基础之面向对象(二)
一点提醒 首先在使用pickle读取load时,需要先把使用到的类import上,否则会报错.在pycharm中使用时不会报错,但在linux或者cmd时就会报错!必须import. 报错提示: Fi ...
- django模板--条件控制标签
条件控制标签 在django模板中可以通过条件控制标签进行逻辑控制,条件控制标签的语法如下: {% if condition1 %} ... {% elif condition2 %} ... {% ...
- python学习笔记-电子书
程序输入和raw_inoput() 内建函数 字符解释 f% :对应小数 >>> print "%s is number %d" % ("python& ...
- Windows下免费的屏幕录制软件——EV录屏——推荐
EV录屏,现在使用起来效果还不错. 软件地址:https://www.ieway.cn/evcapture.html
- 第十三章 RememberMe——《跟我学Shiro》
转发地址:https://www.iteye.com/blog/jinnianshilongnian-2031823 目录贴:跟我学Shiro目录贴 Shiro提供了记住我(RememberMe)的功 ...
- sonar:soanrqube接口api
背景: jenkins+sonar集成了代码扫描,但是发出的邮件不管项目质量是通过还是失败,每次邮件的标题都是jenkins的构建状态,所以需要获取sonar中该项目的扫描结果. 解决: 在sonar ...
- json 格式化输出
C#格式化JSON字符串 很多时候我们需要将json字符串以 { "status": 1, "sum": 9 }这种方式显示,而从服务端取回来的 ...
- 希望对自学的javascript新手有帮助