当前位置:网站首页>【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)
边栏推荐
- Insert mathematical formula in MD document and mathematical formula in typora
- Microcomputer principle - bus and its formation
- Meituan machine test in 2022
- 3. Detailed explanation of Modbus communication protocol
- FAQ | FAQ for building applications for large screen devices
- Foundation: 3 Opencv getting started images and videos
- Shell脚本-echo命令 转义符
- Software Engineer Interview Question brushing website and experience method
- 嵌入式工程师常见面试题2-MCU_STM32
- Centos7 shell script one click installation of JDK, Mongo, Kafka, FTP, PostgreSQL, PostGIS, pgrouting
猜你喜欢

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

Which method is good for the management of fixed assets of small and medium-sized enterprises?

Do you know how data is stored? (C integer and floating point)

Football and basketball game score live broadcast platform source code /app development and construction project

5mo3 UHI HII HII 17mn4 19Mn6 executive standard

如何解决固定资产管理和盘点的难题?

Principle and application of single chip microcomputer timer, serial communication and interrupt system

3. Detailed explanation of Modbus communication protocol

Screenshot tips

猿人学第20题(题目会不定时更新)
随机推荐
Nacos - Configuration Management
Nacos - service discovery
Shell script -if else statement
How to manage fixed assets well? Easy to point and move to provide intelligent solutions
Dynamic proxy
[interview brush 101] linked list
IT 技术电子书 收藏
毕业季,我想对你说
What are the differences between the architecture a, R and m of arm V7, and in which fields are they applied?
Personal decoration notes
中小企业固定资产管理办法哪种好?
Graduation season, I want to tell you
Programming with C language: calculate with formula: e ≈ 1+1/1+ 1/2! …+ 1/n!, Accuracy is 10-6
Daily office consumables management solution
Shell脚本-echo命令 转义符
Shell script -select in loop
Bird recognition app
【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + MQ系列 + NodeJs本地服务 + MySql存储
Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched
Pain points and solutions of equipment management in large factories