当前位置:网站首页>pytorch总结—TENSOR ON GPU
pytorch总结—TENSOR ON GPU
2022-06-29 08:31:00 【TJMtaotao】
用方法 to() 可以将 Tensor 在CPU和GPU(需要硬件⽀支持)之间相互移动。
if torch.cuda.is_available(): #返回True or False #当GPU可用为True,反之则为False
device = torch.device("cuda") # GPU
y = torch.ones_like(x, device=device) # 直接创建⼀个在GPU上的Tensor
x = x.to(device) # 等价于 .to("cuda")
z = x + y
print(z)
print(z.to("cpu", torch.double)) # to()还可以同时更改数据类型
边栏推荐
猜你喜欢
随机推荐
Solutions to ineffective uniapp import components
MySQL uses union all to count the total number of combinations of multiple tables and the number of tables respectively
2022年7月产品经理认证招生简章(NPDP)
(转)MySQL: ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
train_ on_ Batch save the image of the loss function change
train_on_batch保存一下loss函数变化的图像
Calculus Learning
Figure timers in SOC (I): what timers are there in the system?
mongoDB 持久化
YOLO Nano:一种高度紧凑的只看一次的卷积神经网络用于目标检测
训练查看(问题暂存)
Debugging H5 page -weinre and spy debugger real machine debugging
PointNet/Pointnet++训练及测试
jar包和war包
记一些笔试题
专业结构record
Handwritten virtualdom
uniapp引入组件不生效解决方法
Product manager certification enrollment brochure (NPDP) in July 2022
C# 语音端点检测(VAD)实现过程分析








