美文网首页我爱编程
Ubuntu16.04运行TensorFlow出现SSE3等问题

Ubuntu16.04运行TensorFlow出现SSE3等问题

作者: 小远猿 | 来源:发表于2017-08-30 17:11 被阅读0次

    在使用pip安装的TensorFlow的时候,运行会出现如下警告提醒:

    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
    

    为了解决这个问题,我们需要从source安装tensorflow。

    首先卸载安装好的TensorFlow

    ~$ sudo pip uninstall tensorflow
    

    然后clone TensorFlow

    ~$ git clone --recurse-submodules https://github.com/tensorflow/tensorflow
    

    由于编译TensorFlow的时候要用到Bazel,接下来需要安装Bazel

    ~$ sudo apt-get install openjdk-8-jdk
    ~$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
    ~$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
    ~$ sudo apt-get update 
    ~$ sudo apt-get install bazel
    ~$ sudo apt-get upgrade bazel
    

    接着安装依赖

    sudo apt-get install python-numpy python-dev python-pip python-wheel
    

    运行tensorflow配置文件(运行命令后会有输出,全部回车即可)

    ~$ cd tensorflow
    ~$ ./configure
    

    Build支持CPU的tensorflow的pip package:

    ~$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
    

    这个运行非常慢,等运行完成之后使用下面命令build一个.whl文件,该文件在/tmp/tensorflow_pkg文件夹中。

    ~$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
    

    最后安装刚刚build好的.whl文件,至此TensorFlow就安装完成了。

    ~$ sudo pip install /tmp/tensorflow_pkg/tensorflow-1.3.0-cp27-cp27mu-linux_x86_64.whl
    

    验证一下安装是否OK,创建一个ten.py文件:

    import tensorflow as tf
    
    hello = tf.constant('hello tensorflow')
    sess = tf.Session()
    print sess.run(hello)
    

    保存运行

    ~$ python ten.py
    

    得到结果

    hello tensorflow
    

    相关文章

      网友评论

        本文标题:Ubuntu16.04运行TensorFlow出现SSE3等问题

        本文链接:https://www.haomeiwen.com/subject/xbqxjxtx.html