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 ...
随机推荐
- MySQL格式化时间date_format
select date_format(deal_date, '%Y年%m月%d日 %H时%i分%s秒'), date_format(deal_date, '%Y-%m-%d %H:%i:%s') fr ...
- Docs-.NET-C#-指南-语言参考-预处理器指令:#error(C# 参考)
ylbtech-Docs-.NET-C#-指南-语言参考-预处理器指令:#error(C# 参考) 1.返回顶部 1. #error(C# 参考) 2015/07/20 #error 可从代码中的特定 ...
- Android 摇一摇监听实现
package com.loaderman.androiddemo; import android.content.Context; import android.hardware.Sensor; i ...
- 多线程分页处理批量数据--jdbc方式
/** * 同步数据信息到ES * @return */ public boolean syncNhReportSeessToEs(){ long begin = System.currentTime ...
- Web聊天室的实现
Tornado普通方式实现聊天室 普通的http方式连接的话,基本思路是前端页面通过JS重复连接后端服务器. 核心文件:app.py #!/usr/bin/env python # -*- codin ...
- .NET CORE添加引用包
一 .添加服务端引用 1.直接右键添加项目引用,添加后再csproj文件中如下②,也可以直接用这种格式写入csproj文件中 2.直接右键添加DLL引用,添加后再csproj文件中如下③,也可以直接用 ...
- 设置Android模拟器的窗口大小
Android SDK 中两个位置可以设置Android模拟器的窗口大小 1.设置Android模拟器的分辨率 Android Virtual Device Manager中创建AVD时,窗口中部Re ...
- python获取昨日日期
获取昨日日期oneday = datetime.timedelta(days=1) 一天 day = datetime.datetime.strptime(self.date,'%Y-%m-%d') ...
- kali安装chrome
文章搬到自己的网站上,如下: http://101.132.137.140:202/archives/2019-11-25
- c.a.o.c.p.inbound.mysql.rds.RdsBinlogEventParserProxy - prepare to find start position just show master status
2018-12-27 08:39:49.808 [destination = example , address = /127.0.0.1:3308 , EventParser] WARN c.a.o ...