win10安装tensorflow (cpu版)

前提:python

  下载anaconda,而后建立一个python虚拟环境:git

  命令: conda create -n tf_cpu python=3.6       # (tf_cpu  是这个虚拟环境的名字)github

  切换到该虚拟环境下:windows

  命令:activate tf_cpu性能

  查看全部虚拟环境列表this

  命令:conda env listspa

不完美版tensorflow安装:ip

  切换到本身的虚拟环境下后,直接利用pip安装:get

  命令:pip install --upgrade --ignore-installed tensorflowit

  这样安装结束后tensorflow就能够使用了,可是有一个问题,会发出警告:

    Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

  缘由是下载的TensorFlow的版本不支持cpu的AVX2编译,可是不影响正常使用,只是好像性能不能获得完美发挥。

  骗本身的解决方式:

    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,或者删掉这个虚拟python环境,从新来一遍,此次不适用pip直接安装tensorflow了。

    去这儿:https://github.com/fo40225/tensorflow-windows-wheel 下载相应的tensorflow,手动安装。

    我是win10+python3.6 我下载的是这个:

    https://github.com/fo40225/tensorflow-windows-wheel/tree/master/1.6.0/py36/CPU/avx2

    而后在本地手动安装就ok了。

可是安装成功后,运行时没有那个警告了,可是有会有另外一个:

   FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.

  这是由于numpy版本太高了,将版本降下来就ok了:pip install numpy==1.16.4

相关文章
相关标签/搜索