zoukankan      html  css  js  c++  java
  • linux 运行tensorflow文件缺少_bz2问题及解决

    今天,终于把如何在linux服务器上运行tensorflow程序的问题解决:

    1、首先要在服务器上python下安装tensorflow(要看好是在python2还是python3下安装,还要看好是CPU版本还是GPU版本)

    2、确保tensorflow测试程序正常运行,

    例:

    import tensorflow as tf
     
    with tf.device('/cpu:0'):
        a = tf.constant([1.0,2.0,3.0],shape=[3],name='a')
        b = tf.constant([1.0,2.0,3.0],shape=[3],name='b')
    with tf.device('/gpu:1'):
        c = a+b
       
    #注意:allow_soft_placement=True表明:计算设备可自行选择,如果没有这个参数,会报错。
    #因为不是所有的操作都可以被放在GPU上,如果强行将无法放在GPU上的操作指定到GPU上,将会报错。
    sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True,log_device_placement=True))
    #sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
    sess.run(tf.global_variables_initializer())
    
    print(sess.run(c))

    3、确保你写的程序已经分配GPU或CPU,配置后在服务器上运行即可

    tf.device('/cpu:0')
    config=tf.ConfigProto(allow_soft_placement=True,log_device_placement=True)
     
  • 相关阅读:
    Jenkins Install
    提高C#代码质量的22条准则
    游戏程序员英文指南
    苹果设备内存指南
    Unity符号表
    UI优化策略-UI性能优化技巧
    C# 语言历史版本特性
    CPU SIMD介绍
    Unity渲染性能指标
    关于JMeter线程组中线程数,Ramp-Up Period,循环次数之间的设置概念
  • 原文地址:https://www.cnblogs.com/strong-FE/p/10153028.html
Copyright © 2011-2022 走看看