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 ...
随机推荐
- android studio: 9:57 Unsupported Modules Detected: Compilation is not supported for following modules: map, app, ota, MediaEditor, rcLcmSercive, DroneSDK, qrcodelibrary, rcService, speechService. Unfo
Android studio Error “Unsupported Modules Detected: Compilation is not supported for following modul ...
- 设计-Int(4)和Int(11)谁更美
设计-Int(4)和Int(11)谁更美 [缘起] 大家平时在进行数据库设计的时候,如果遇到需要存储整数类型的数据的时候,通常会优先使用Int这个整数类型,在处理20亿级别的正负数值存储上,Int类型 ...
- CentOS7下JSP连接Mysql
实验环境如下: youxi1 CentOS7.5 Tomcat8.5.35 192.168.5.101 youxi2 CentOS7.5 Mysql5.7.20 192.168.5.102 (1).下 ...
- 123457123456#0#---com.threeapp.ErTongShuXueKoSuan01----儿童宝宝数学口算01
com.threeapp.ErTongShuXueKoSuan01----儿童宝宝数学口算01
- (十八)Centos之firewall 防火墙命令
如果你的系统上没有安装使用命令安装 #yum install firewalld //安装firewalld 防火墙 开启服务 # systemctl start firewalld.service ...
- DOS与cmd(windows)
dos是计算机的最初期的操作系统,对电脑操作必须输入各种dos命令窗口,可以理解成运行计算机机器内部语言,知道编程吗?其实早期dos命令操作系统就是运行计算机内部的编程命令,因此操作人员都必须具有一定 ...
- iOS-tabBar切换不同控制器封装(自定义导航+自定义uiviewcontroler+系统自带tabbar+自定义tabbarController)
首先,一个app的搭建环境非常重要.既要实现基本功能,又要考虑后期优化的性能. 现在很多应用不仅仅是系统自带的控制器,由于需求复杂,基本上需要自定义多控制器来管理. 新建一个BasicNavigati ...
- Win 7 环境上,ThingsBoard安装及启动
一.参考官方网址进行Thingsboard的下载与安装, 官方教程https://thingsboard.io/docs/user-guide/install/windows/#step-2-thin ...
- 【数据库开发】Redis数据库服务器启动配置
Redis简介 redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合).zset(sor ...
- 最新 翔通动漫java校招面经 (含整理过的面试题大全)
从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.翔通动漫等10家互联网公司的校招Offer,因为某些自身原因最终选择了翔通动漫.6.7月主要是做系统复习.项目复盘.Leet ...