当前位置:网站首页>【pytorch学习】torch.device
【pytorch学习】torch.device
2022-07-01 09:03:00 【Enzo 想砸电脑】
1. torch.device代表的含义
torch.device代表将torch.tensor分配到的设备的对象
(简单点说,就是分配到你的CPU还是GPU上,以及哪块GPU上)
2. torch.device的参数解读
torch.device包含一个设备类型('cpu’或’cuda’设备类型)和可选的设备的序号。
如果设备序号不存在,则为当前设备
例如,torch.Tensor用设备构建’cuda’的结果等同于’cuda:X’,其中X是torch.cuda.current_device()的结果。
3. 构造torch.device的两种方式
- 通过字符串
>>> torch.device('cpu')
device(type='cpu')
>>> torch.device('cuda:0')
device(type='cuda', index=0)
>>> torch.device('cuda') # current cuda device
device(type='cuda')
- 通过字符串和设备编号的形式
>>> torch.device('cpu', 0)
device(type='cpu', index=0)
>>> torch.device('cuda', 0)
device(type='cuda', index=0)
边栏推荐
- Shell脚本-while循环详解
- Matlab tips (16) consistency verification of matrix eigenvector eigenvalue solution -- analytic hierarchy process
- 猿人学第20题(题目会不定时更新)
- Shell script - special variables: shell $, $*, [email protected], $$$
- JCL 和 SLF4J
- Advanced C language pointer (Part 2)
- Shell脚本-case in语句
- Interrupt sharing variables with other functions and protection of critical resources
- Jeecg restart alarm 40001
- Log4j 日志框架
猜你喜欢

Only in China! Alicloud container service enters the Forrester leader quadrant

jeecg 重启报40001

【MFC开发(16)】树形控件Tree Control

1. Connection between Jetson and camera
![[MFC development (17)] advanced list control list control](/img/e8/24c52cb51defc6c96b43c2ef3232ff.png)
[MFC development (17)] advanced list control list control

嵌入式工程师面试题3-硬件

【MFC开发(17)】高级列表控件List Control

19Mn6 German standard pressure vessel steel plate 19Mn6 Wugang fixed binding 19Mn6 chemical composition

Dynamic proxy

FAQ | FAQ for building applications for large screen devices
随机推荐
序列化、监听、自定义注解
Bimianhongfu queren()
Programming with C language: calculate with formula: e ≈ 1+1/1+ 1/2! …+ 1/n!, Accuracy is 10-6
Pain points and solutions of equipment management in large factories
C语言学生信息管理系统
V79.01 Hongmeng kernel source code analysis (user mode locking) | how to use the fast lock futex (Part 1) | hundreds of blogs analyze the openharmony source code
易点易动助力企业设备高效管理,提升设备利用率
19Mn6 German standard pressure vessel steel plate 19Mn6 Wugang fixed binding 19Mn6 chemical composition
ARM v7的体系结构A、R、M区别,分别应用在什么领域?
Nacos - service discovery
Shell script echo command escape character
Shell脚本-echo命令 转义符
Vsync+ triple cache mechanism +choreographer
【MFC开发(17)】高级列表控件List Control
嵌入式工程师面试-常问问题集
In the middle of the year, where should fixed asset management go?
类加载
[interview brush 101] linked list
动态代理
Differences among tasks, threads and processes