Pytorch中的tensor又包括CPU上的数据类型和GPU上的数据类型,一般GPU上的Tensor是CPU上的Tensor加cuda()函数得到。

一般系统默认是torch.FloatTensor类型。例如data = torch.Tensor(2,3)是一个2*3的张量,类型为FloatTensor;

data.cuda()就转换为GPU的张量类型,torch.cuda.FloatTensor类型。

if cuda:
dtype = torch.cuda.FloatTensor
else:
if torch.cuda.is_available():
print("WARNING: You have a CUDA device, so you should probably set cuda=True")
dtype = torch.FloatTensor

torch.cuda.FloatTensor的更多相关文章

  1. one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [3, 1280, 28, 28]], which is output 0 of LeakyReluBackward1, is at version 2;

    RuntimeError: one of the variables needed for gradient computation has been modified by an inplace o ...

  2. [报错]-RuntimeError: Input type (torch.cuda.HalfTensor) and weight type (torch.cuda.FloatTensor) should be the same

    RuntimeError: Input type (torch.cuda.HalfTensor) and weight type (torch.cuda.FloatTensor) should be ...

  3. 常见错误 RuntimeError: expected type torch.FloatTensor but got torch.cuda.FloatTensor

    https://www.jianshu.com/p/0be7a375bdbe https://blog.csdn.net/qq_38410428/article/details/82973895 计算 ...

  4. pytorch torch.Stroage();torch.cuda()

    转自:https://ptorch.com/news/52.html torch.Storage是单个数据类型的连续的一维数组,每个torch.Tensor都具有相同数据类型的相应存储.他是torch ...

  5. 【FAQ】P3. 为什么 torch.cuda.is_available() 是 False

    为什么 torch.cuda.is_available() 是 False torch.cuda.is_available(),这个指令的作用是看,你电脑的 GPU 能否被 PyTorch 调用. 如 ...

  6. pytorch,cuda8,torch.cuda.is_available return flase (ubuntu14)

    因为ubuntu 系统是14.0的,安装pytorch1.0的时候,本身已经安装好了cuda8,在验证gpu的时候,torch.cuda.is_available()返回false 安装命令是: co ...

  7. PyTorch官方中文文档:torch.Tensor

    torch.Tensor torch.Tensor是一种包含单一数据类型元素的多维矩阵. Torch定义了七种CPU tensor类型和八种GPU tensor类型: Data tyoe CPU te ...

  8. Pytorch基本变量类型FloatTensor与Variable

    pytorch中基本的变量类型当属FloatTensor(以下都用floattensor),而Variable(以下都用variable)是floattensor的封装,除了包含floattensor ...

  9. torch.Tensor文档学习笔记

    A torch.Tensor is a multi-dimensional matrix containing elements of a single data type. 张量(torch.Ten ...

随机推荐

  1. SpringBoot nohup启动

    #!/bin/sh nohup java -jar /data/wwwroot/xxx.jar > /data/wwwlogs/xxx.log >&

  2. KALI 2017 X64安装到U盘

    KALI 2017 X64安装到U盘启动(作者:黑冰) 此方法为虚拟机方法,自认为成功率很高,已经成功安装过16,32G U盘​,但也不排除有些人用拷碟方法安装这里我仅介绍虚拟机安装方法. ​1.准备 ...

  3. Ubuntu 安装MySQL并打开远程连接

    首先使用su命令切换到root账户 在用apt-get install mysql-server命令获取到MySQL的服务 等待下载安装,按照提示输入MySQL的密码 安装完成后对mysqld.cnf ...

  4. javaScript中this的指向?

    javaScript中this对象是在运行时基于函数的执行环境绑定的,在全局函数中,this等于window,而当函数被作为某个对象的方法调用时,this等于那个对象. 但在实际中,代码环境复杂,th ...

  5. c++存储区域

    来自:https://www.cnblogs.com/simonote/articles/3146038.html 在C++中,内存分成5个区,他们分别是堆.栈.自由存储区.全局/静态存储区和常量存储 ...

  6. HBase查询速度慢原因排查

    问题:通过HBase访问服务在HBase中查询 ASSET_NORMAL 表速度很慢 如下,查询一条数据需要2.970s时间: 如下,统计总条数需要14.675s时间: HBase访问服务部署了3个节 ...

  7. 解决css中display:inline-block的兼容问题

    *display:inline; *zoom:1; 不多说,ie6/7直接在元素添加以上的属性即可.

  8. IDEA中如何部署tomcat

    1.添加tomcat 2.添加tomcat所依赖的war包 test009.war包刚开始可能不存在,这个时候需要将maven项目进行打包,然后点击“+”之后就会出现一个和项目名同名的war包,选中就 ...

  9. 面试题23从上到下打印二叉树+queue操作

    //本题思路就是层次遍历二叉树,使用一个队列来模拟过程 /* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *ri ...

  10. 5、mysql的连接查询

    1.内联查询 >inner join 或 join 2.外联查询 (1)左连接 >left outer join 或 left join (2)右连接 >right outer jo ...