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. swoole之内存

    一.代码 <?php // 可以用来数据共享 // 执行完后 自动释放 // 创建内存表 $table = new swoole_table(1024); // 内存表增加一列 $table-& ...

  2. AngularJS1.X指令

    <!DOCTYPE html> <html ng-app='myApp'> <head> <meta charset="utf-8"> ...

  3. SystemVerilog基本语法总结(下)

    2018年IC设计企业笔试题解析-(验证方向) 1.请简述:定宽数组,动态数组,关联数组,队列四种数据类型的各自特点.解析:(1)定宽数组:其宽度在声明的时候就指定了,故其宽度在编译时就确定了.(2) ...

  4. 如何在SecureCRT中上传文件到linux服务器上

    1.使用yum安装运行命令sudo yum install lrzsz(默认使没有安装运行命令的) 2.上传命令rz  下载命令sz  

  5. Day3-K-Can you solve this equation? HDU2199

    Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and ...

  6. 092、Java中String类之字符串内容比较

    01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...

  7. centos 安装 memcached

    centos 安装 memcached 1. 安装依赖: libeventyum install libevent-devel 2. 获取最新版本wget http://memcached.org/l ...

  8. 17 MySQL的小技巧

    1.正则表达式的使用   ^ 在字符串开始处进行匹配 $ 在字符串末尾处进行匹配 . 匹配任意单个字符,包括换行符 [...]  匹配出括号内的任意字符 [^...]  匹配不出括号内的任意字符 a* ...

  9. 设置zabbix (3.4.2)添加监控项,触发器,让CPU使用超过85%就报警:

    zabbix (3.4.2)添加监控项,触发器,让CPU使用超过85%就报警: zabbix自带模板有一个 Template OS Linux模板.这个模板有监控CPU的监控项,如果没有添加一个监控项 ...

  10. Activity的生命周期及协同作用

    生命周期 onCreate:创建Activity的实例对象的方法 onStart:启动当前的activity实例的方法 onResume:如果该方法执行,页面的实例和用户即可以交互 onPause:如 ...