当前位置:网站首页>Assertionerror: invalid device ID and runtimeerror: CUDA error: invalid device ordinal
Assertionerror: invalid device ID and runtimeerror: CUDA error: invalid device ordinal
2022-04-23 20:48:00 【NuerNuer】
I am using torch These two problems occur when multiple cards are parallel .
## Question 1 :AssertionError: Invalid device id, Invalid device id
The reason for this : Combined with code interpretation :
import ...
os.environ["CUDA_VISIBLE_DEVICES"] = "2,3"
model = model(...)
torch.cuda.set_device(2)
model = torch.nn.DataParrel(model, device_ids=[2,3])
The reason for the error :os.environ["CUDA_VISIBLE_DEVICES"] = "2,3" This statement will the original divice:2 and device:3 The number of is mapped to device:0 and device:1, So in set_device Error reporting at time , Invalid device id
terms of settlement : Method 1 : take os.environ Delete . If some cards are occupied, you have to use os.environ To set up available devices , Use method 2 : Follow the remapped number , example set_device(0)
## Question two :RuntimeError: CUDA error: invalid device ordinal
The reason for this : Combining with the code
import ...
os.environ["CUDA_VISIBLE_DEVICES"] = "2,3"
model = model(...)
model = torch.nn.DataParrel(model, device_ids=[2,3])
The reason for the error : Same as above ,os.environ["CUDA_VISIBLE_DEVICES"] = "2,3" This statement will the original divice:2 and device:3 The number of is mapped to device:0 and device:1, So in execution torch.nn.DataParrel When an error
terms of settlement : Method 1 : take os.environ Delete . If some cards are occupied, you have to use os.environ To set up available devices , Use method 2 : Follow the remapped number , example :
model = torch.nn.DataParrel(model, device_ids=[0,1])
Recommend an article , Simple implementation of multi card parallel :
https://muzhan.blog.csdn.net/article/details/109318226
https://www.codeleading.com/article/2345206500
https://blog.csdn.net/weixin_34233421/article/details/91396978
版权声明
本文为[NuerNuer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210545522657.html
边栏推荐
- Fastdfs mind map
- 浅谈数据库设计之三大范式
- Recommended usage scenarios and production tools for common 60 types of charts
- Selenium displays webdriverwait
- Learn to C language fourth day
- matplotlib. Pyplot partition drawing
- Pytorch preserves different forms of pre training models
- Common problems in deploying projects with laravel and composer for PHP
- Easy to use nprogress progress bar
- On the three paradigms of database design
猜你喜欢
亚马逊和Epic将入驻,微软应用商城向第三方开放
Devaxpress report replay: complete the drawing of conventional two-dimensional report + histogram + pie chart
Matlab matrix index problem
Resolve the eslint warning -- ignore the warning that there is no space between the method name and ()
CUDA, NVIDIA driver, cudnn download address and version correspondence
高薪程序员&面试题精讲系列91之Limit 20000加载很慢怎么解决?如何定位慢SQL?
41. The first missing positive number
Identifier CV is not defined in opencv4_ CAP_ PROP_ FPS; CV_ CAP_ PROP_ FRAME_ COUNT; CV_ CAP_ PROP_ POS_ Frames problem
Linux中,MySQL的常用命令
內網滲透之DOS命令
随机推荐
Come in and teach you how to solve the problem of port occupation
pytorch 1.7. The model saved by X training cannot be loaded in version 1.4 or earlier
Selenium displays webdriverwait
mmap、munmap
高薪程序员&面试题精讲系列91之Limit 20000加载很慢怎么解决?如何定位慢SQL?
Some thoughts on super in pytorch, combined with code
"Meta function" of tidb 6.0: what is placement rules in SQL?
Devaxpress report replay: complete the drawing of conventional two-dimensional report + histogram + pie chart
深入探究ASP.NET Core读取Request.Body的正确方式
Solve the Chinese garbled code of URL in JS - decoding
Imitation Baidu map realizes the three buttons to switch the map mode by automatically shrinking the bottom
Resolve the error - error identifier 'attr_ id‘ is not in camel case camelcase
浅谈数据库设计之三大范式
电脑越用越慢怎么办?文件误删除恢复方法
Is qiniu school useful and is the recommended securities account safe
Cmake project under vs2019: calculating binocular parallax using elas method
C# 知识
MySQL数据库常识之储存引擎
MySQL 存储过程和函数
An error occurs when the addressable assets system project is packaged. Runtimedata is null