zoukankan      html  css  js  c++  java
  • [教程]Tensorflow + win10 + CPU + Python3.6+ 安装教程

    由于各种原因,清华镜像源已经彻底挂掉了,但是目前网上的各种教程基本上都是采取设置清华镜像源来加快下载速度,所以这给小白带来了很大的困扰!这里我将通过合理上网工具来直接下载源镜像。

    注意:本次教程适用于Win10系统下已经安装Anaconda,并且安装了Python3.6版本及以上的用户。

    加速工具

    下载链接(提取码:v4lg)

    使用方法:将文件解压后,整个文件夹复制粘贴到C盘根目录,点击SSLSpeedy.exe运行程序,账号:pinghang,密码:ph123456 。根据实际网速调整接入节点。

    以下操作均在Anaconda Prompt下完成,请先确认已经安装了Anaconda3 + Pycharm。

    更新pip工具

    python -m pip install --upgrade pip
    

    检查环境

    conda info --envs
    

    输出结果:

    # conda environments:
    #
    base                  *  D:PythonAnaconda3
    

    说明你已经安装了Anaconda,未安装过Tensorflow的环境。

    创建环境

    conda create -n tensorflow python=3.6
    

    输出结果:

    Collecting package metadata: done
    Solving environment: done
    
    ## Package Plan ##
    
      environment location: D:PythonAnaconda3envs	ensorflow
    
      added / updated specs:
        - python=3.6
    
    
    The following NEW packages will be INSTALLED:
    
      certifi            pkgs/main/win-64::certifi-2019.3.9-py36_0
      pip                pkgs/main/win-64::pip-19.1.1-py36_0
      python             pkgs/main/win-64::python-3.6.8-h9f7ef89_7
      setuptools         pkgs/main/win-64::setuptools-41.0.1-py36_0
      sqlite             pkgs/main/win-64::sqlite-3.28.0-he774522_0
      vc                 pkgs/main/win-64::vc-14.1-h0510ff6_4
      vs2015_runtime     pkgs/main/win-64::vs2015_runtime-14.15.26706-h3a45250_4
      wheel              pkgs/main/win-64::wheel-0.33.4-py36_0
      wincertstore       pkgs/main/win-64::wincertstore-0.2-py36h7fe50ca_0
      
    Proceed ([y]/n)?
    

    输入

     y
    

    输出结果

    Preparing transaction: done
    Verifying transaction: done
    Executing transaction: done
    #
    # To activate this environment, use
    #
    #     $ conda activate tensorflow
    #
    # To deactivate an active environment, use
    #
    #     $ conda deactivate
    

    激活Tensorflow

    activate tensorflow
    

    输出结果

    (tensorflow) C:UsersGShang>
    

    前面的括号中出现 tensorflow ,说明已经激活好

    安装Tensorflow

    pip install  --upgrade tensorflow
    

    测试安装是否成功

    在Pycahrm中新建py文件,内容为

    import tensorflow as tf
    hello = tf.constant('Hello, TensorFlow!')
    sess = tf.Session()
    print(sess.run(hello))
    

    输出:

    D:PythonAnaconda3python.exe E:/python/tensor.py
    2019-06-11 08:41:49.174192: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
    b'Hello, TensorFlow!'
    
    Process finished with exit code 0
    

    说明已经安装成功,

    关于报错的解释

    tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
    

    资料参考:
    Advanced Vector Extensions ,AVX, also known as Sandy Bridge New Extensions)
    先进的矢量扩展(AVX,也称为桑迪桥新的扩展)是从英特尔和英特尔在2008年3月提出的微处理器的X86指令集架构的扩展,第一次由英特尔支持,在第2011季度和以后的SoeBoE桥处理器装运。AMD与推土机处理器航运在Q3
    2011。AVX提供了新的特性、新的指令和新的编码方案。AVX2将大多数整数命令扩展为256位,并介绍了融合乘法累加(FMA)操作。AVX-512扩展AVX到512位支持使用一个新的EVEX前缀编码由英特尔提出的2013年7月,第一次支持英特尔与骑士着陆处理器,在2016装运。

    import os os.environ["TF_CPP_MIN_LOG_LEVEL"]='1' # 这是默认的显示等级,显示所有信息 
    os.environ["TF_CPP_MIN_LOG_LEVEL"]='2' # 只显示 warning 和 Error 
    os.environ["TF_CPP_MIN_LOG_LEVEL"]='3' # 只显示 Error 
    

    参考网友的评论解释:这个意思其实是,您下载的TensorFlow太low了,根本没有通过兼容AVX来Compile。如果您下载源代码在该电脑上重新compile,就可以支持AVX。其实你的电脑是支持AVX的,只是编译好的TensorFlow不支持。

    解决办法

    在最顶行写入

    import os
    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' 
    
  • 相关阅读:
    https://wuzhuti.cn/2175.html
    http://www.importnew.com/10937.html
    http://blog.sina.com.cn/s/blog_62e1faba010147k4.html
    http://www.cnblogs.com/langtianya/archive/2013/02/01/2889682.html
    http://www.binghe.org/2010/03/use-httpsurlconnection-in-java/
    http://risheng.iteye.com/blog/1876573
    http://blog.csdn.net/rongyongfeikai2/article/details/41659353
    http://zhidao.baidu.com/link?url=inouJq69pK4PVM2L26fvnxXfRKhJ1uKmttgVqIEqld14SEUa8JzXZfRYHS3qdltqMXBgEQycFsF8AI9DlSoH4_
    http://blog.csdn.net/szwangdf/article/details/23432783
    win8连接蓝牙听歌
  • 原文地址:https://www.cnblogs.com/gshang/p/11001845.html
Copyright © 2011-2022 走看看