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)
     
  • 相关阅读:
    获取app下载链接
    查找文件的路径
    回忆基础:制作plist文件
    Ping++中的AlipaySDK和AlicloudUTDID冲突解决方案
    CocoaPods常用操作命令
    自签名配置HTTPS
    Instruments10 分析某个类中方法的执行时间
    iOS KVC/KVO
    iOS 系统架构及常用框架
    LINQ to SQLite完美解决方案
  • 原文地址:https://www.cnblogs.com/strong-FE/p/10153028.html
Copyright © 2011-2022 走看看