关于使用TensorFlow跑深度学习的建议

关于使用系统的问题.

最好使用ubuntu安装TensorFlow而不是Win10?

性能:性能对比到底有多大的问题!
GTX1070在win10 64与ubuntu 18.04.2
运行矩阵运算速度测试-同一台电脑,CUDA10.0,驱动430.26,cuDNN为对应版本最近!
时间上误差极小:8.14 V S8.57,结果是ubuntu下,居然不如win10.
TensorFlow版本为:1.14。

config=tf.ConfigProto(allow_soft_placement=True,log_device_placement=True)
是否建议使用Docker来进行运行对应的代码.

Docker很火,很多人都喜欢拿来跑深度,性能到底怎么样?
window下的docker的性能远远的低于ubuntu下docker的性能,那么到底差距多少?
直接结论:

  • window10 64下,基于系统的问题性能不容乐观,大概也就80%不到!
  • ubuntu18.04.2LTS下 几乎没有 太大区别,大概是同一代码时间花费为:host VS docker = 54:56
tensorflow版本的问题.

我很负责任的说:tensorflow1.14的运算上不如tensorflow1.8版本!
时间为:8.57 VS 6.19

  • 测试所用代码.
    import sys
    import numpy as np
    import tensorflow as tf
    from datetime import datetime
    
    config = tf.ConfigProto(allow_soft_placement=False)
    
    device_name = sys.argv[1]  # Choose device from cmd line. Options: gpu or cpu
    shape = (int(sys.argv[2]), int(sys.argv[2]))
    if device_name == "gpu":
        device_name = "/gpu:0"
    else:
        device_name = "/cpu:0"
    
    with tf.device(device_name):
        random_matrix = tf.random_uniform(shape=shape, minval=0, maxval=1)
        dot_operation = tf.matmul(random_matrix, tf.transpose(random_matrix))
        sum_operation = tf.reduce_sum(dot_operation)
    
    startTime = datetime.now()	
    with tf.Session(config=config) as session:
        result = 0.0
        for i in range(1000):
            result += session.run(sum_operation)
            print(result)
    
    # It can be hard to see the results on the terminal with lots of output -- add some newlines to improve readability.
    print("\n" * 3)
    print("Shape:", shape, "Device:", device_name)
    print("Time taken:", str(datetime.now() - startTime))	
    """
    # use:
    python this.py gpu 10000
    """
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值