Tensorflow搭载GPU与CPU计算与训练==2

29 篇文章 2 订阅
5 篇文章 0 订阅
基础:Tensorflow选择GPU&CPU计算与训练==1

1 默认模式

1.0 默认CPU

  • 结果:计算结果
CPU calculator result is : [250.]
CPU calculator time consuming is: 0.000690937042236

1.2 默认GPU

  • 结果:计算结果
GPU calculator result is : [250.]
GPU calculator time consuming is: 0.0177528858185

2 指定模式

2.1 全局指定

2.1.0 全局CPU(Tensorflow)

CPU calculator result is : [250.]
CPU calculator time consuming is: 0.00070595741272

2.1.0 全局CPU(Tensorflow-gpu)

CPU calculator result is : [250.]
CPU calculator time consuming is: 0.0183000564575

2.1.2 全局GPU(Tensorflow-gpu)

GPU calculator result is : [250.]
GPU calculator time consuming is: 0.0175189971924

2.2 局部指定

2.2.1 局部CPU(Tensorflow)

CPU calculator result is : [250.]
CPU calculator time consuming is: 0.000771045684814

2.2.1 局部CPU(Tensorflow-gpu)

CPU calculator result is : [250.]
CPU calculator time consuming is: 0.01775598526

2.2.2 局部GPU

GPU calculator result is : [250.]
GPU calculator time consuming is: 0.0177412033081

3 总结

3.1 结果

耗时/s默认全局Tensorflow模块Tensorflow全局Tensorflow-gpu模块Tensorflow-gpu
CPU0.0006909370422360.000705957412720.0007710456848140.01830005645750.01775598526
GPU0.0177528858185//0.01751899719240.0177412033081

3.2 结论

  • 从数学计算方面比较,CPU计算速度高于GPU;图像处理GPU远高于CPU;
  • 单纯的CPU环境,进行计算和GPU环境中的CPU计算速度不同,且纯CPU计算速度高于GPU环境的CPU计算速度;如果计算任务仅CPU即可满足,无需在GPU环境中调用CPU,如果需要GPU和CPU分模块计算,可在GPU环境中调用CPU;

4 提示与设备信息

4.1 使用CPU

  • 结果:提示信息
2018-12-14 17:46:49.410201: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Device mapping:
/job:localhost/replica:0/task:0/device:XLA_CPU:0 -> device: XLA_CPU device
2018-12-14 17:46:49.415702: I tensorflow/core/common_runtime/direct_session.cc:307] Device mapping:
/job:localhost/replica:0/task:0/device:XLA_CPU:0 -> device: XLA_CPU device
  • 结果:设备信息
add: (Add): /job:localhost/replica:0/task:0/device:CPU:0
2018-12-14 17:46:49.416609: I tensorflow/core/common_runtime/placer.cc:927] add: (Add)/job:localhost/replica:0/task:0/device:CPU:0
v1: (Const): /job:localhost/replica:0/task:0/device:CPU:0
2018-12-14 17:46:49.416649: I tensorflow/core/common_runtime/placer.cc:927] v1: (Const)/job:localhost/replica:0/task:0/device:CPU:0
v2: (Const): /job:localhost/replica:0/task:0/device:CPU:0
2018-12-14 17:46:49.416680: I tensorflow/core/common_runtime/placer.cc:927] v2: (Const)/job:localhost/replica:0/task:0/device:CPU:0

4.2 使用GPU

  • 结果:提示信息
2018-12-14 18:09:48.631634: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-12-14 18:09:48.739205: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:892] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-12-14 18:09:48.739452: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties: 
name: Tesla P4 major: 6 minor: 1 memoryClockRate(GHz): 1.1135
pciBusID: 0000:00:08.0
totalMemory: 7.43GiB freeMemory: 7.31GiB
2018-12-14 18:09:48.739482: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: Tesla P4, pci bus id: 0000:00:08.0, compute capability: 6.1)
Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla P4, pci bus id: 0000:00:08.0, compute capability: 6.1
2018-12-14 18:09:48.816739: I tensorflow/core/common_runtime/direct_session.cc:299] Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla P4, pci bus id: 0000:00:08.0, compute capability: 6.1
  • 结果:设备信息
add: (Add): /job:localhost/replica:0/task:0/device:GPU:0
2018-12-14 18:09:48.817553: I tensorflow/core/common_runtime/placer.cc:874] add: (Add)/job:localhost/replica:0/task:0/device:GPU:0
v2: (Const): /job:localhost/replica:0/task:0/device:GPU:0
2018-12-14 18:09:48.817586: I tensorflow/core/common_runtime/placer.cc:874] v2: (Const)/job:localhost/replica:0/task:0/device:GPU:0
v1: (Const): /job:localhost/replica:0/task:0/device:GPU:0
2018-12-14 18:09:48.817602: I tensorflow/core/common_runtime/placer.cc:874] v1: (Const)/job:localhost/replica:0/task:0/device:GPU:0

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天然玩家

坚持才能做到极致

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值