成功解决Your CPU supports instructions that this TensorFlow binary was not compiled to use AVX AVX2

**

避坑必读,强烈建议

1.说明你电脑支持AVX2,而你的tesorflow版本不支持,重建虚拟环境重装tensorflow
2.离线安装tensorflow,下载安装包之后再安装
3.如果遇到新问题,请认真看提示,不要乱百度!!!

这几步需要前提准备:

准备1下载安装Anaconda3

访问清华镜像下载:https://mirrors.tuna.tsinghua.edu.cn/
安装时,全程点击"下一步",完成即可
注:也可以参考其他任何教程,假设安装路径为 G:\Anaconda3
注:本节使用Anaconda3-5.1.0-Windows-x86_64.exe(对应我电脑系统win10-(64位)版)

准备2:创建虚拟环境tf1

使用管理员身份打开Anaconda Prompt,创建虚拟环境tf1(注意本次python版本3.6.0,tf1可以自行定义)
conda create --name tf1 python=3.6.0

安装Tensorflow正式开始

  • 1.访问这个镜像网址下载tensorflow
    https://gitcode.net/mirrors/fo40225/tensorflow-windows-wheel/
    根据需求下载,本节测试对应python6.3.0的版本tensorflow-1.4.0-cp36-cp36m-win_amd64.whl
  • 2. 在Anaconda中创建文件夹存放
    G:\Anaconda3\Lib\tensor(Lib下的路径自己创建),将下载文件复制拷贝到该文件中
  • 3.切换到虚拟环境tf1
    管理员身份打开Anaconda Prompt,切换到对应的虚拟环境tf1下:
    env list #查看虚拟环境
    conda activate tf1
  • 4.跳转目录
    跳转到G:\Anaconda3\Lib\tensor 目录中
    G: (回车)
    cd Anaconda3\Lib\tensor\
  • 5.安装离线的ensorflow
    在tf1环境下,安装离线的文件
    pip install tensorflow-1.4.0-cp36-cp36m-win_amd64.whl
  • 6. 在tf1环境下测试通过python导入tensorflow
    在Anaconda Prompt中 tf1虚拟环境下执行:
    python (回车)
    import tensorflow as tf #导入tensorflow
    print(tf.version) #打印tensorflow 版本
    print( tf.path ) #打印tensorflow 路径
  • 7.安装jupyter notebook
    (推荐使用)conda install jupyter notebook
  • 8.在tf1环境下安装ipykernel
    jupyter kernelspec list #查看tf1环境下jupyter所有可用的 kernels
    upyter kernelspec remove 名称 (名称为你想删除的现有名称)
    pip install ipykernel
    python -m ipykernel install --name tf1
  • 9. 在tf1环境下测试通过jupyter notebook导入tensorflow
    jupyter notebook
    网页自动打开后,New–>ft1,然后写入程序
    import tensorflow as tf
    print(tf.version)
    print( tf.path )

遇到其他问题解决办法

  • 【1】如果出现:ImportError: cannot import name ‘AsyncGenerator’,
    请关闭所有juppyter notebook和窗口重新打开,然后激活tf1的环境 ,再执行:
    python -m ipykernel install --name tf1

  • 【2】如果需要使用:matplotlib,请独立安装下载好的安装包

  • **下载后安装:matplotlib-2.2.5-cp36-cp36m-win_amd64.whl
    cp36代表的是python的版本,如python3.6.0就是cp36
    win_amd64指的是windows系统(64位)
    选择自己对应的matplotlib(其他模块也一样),下载到scripts目录下。
    打开cmd,输入cd ×××/×××/×××/scripts(你的scripts路径)
    然后用pip下载whl文件,
    pip install matplotlib-2.2.5-cp36-cp36m-win_amd64.whl
    因为,你按照上述方法安装完后请看一下自己的numpy版本=1.19.5
    如果直接使用pip install matplotlib指令,会下载其他支持库,其中有一个为numpy=1.13.1,这样就会出错。所以还是先下载好独立安装包,然后再pip安装。
    但是这样,导入时还会出现一个新错误
    ‘version_info’ object has no attribute ‘version
    不要怕
    打开以下文件:G:\Anaconda3\envs\tf1\Lib\site-packages\pyparsing,下的__init__.py文件
    init.py 对应位置(这一段)

class version_info(NamedTuple):
    major: int
    minor: int
    micro: int
    releaselevel: str
    serial: int
 
    @property
    def __version__(self):
        return "{}.{}.{}".format(self.major, self.minor, self.micro) + (
            "{}{}{}".format(
                "r" if self.releaselevel[0] == "c" else "",
                self.releaselevel[0],
                self.serial,
            ),
            "",
        )[self.releaselevel == "final"]
 
    def __str__(self):
        return "{} {} / {}".format(__name__, self.__version__, __version_time__)
 
    def __repr__(self):
        return "{}.{}({})".format(
            __name__,
            type(self).__name__,
            ", ".join("{}={!r}".format(*nv) for nv in zip(self._fields, self)),
        )

init.py 修改后

def __init__(self,major:int,minor:int,micro:int,releaselevel:str,serial:int):   
    self.major = major
    self.minor = minor
    self.micro = micro
    self.releaselevel = releaselevel
    self.serial = serial
@property
def __version__(self):
    return "{}.{}.{}".format(self.major, self.minor, self.micro) + (
        "{}{}{}".format(
            "r" if self.releaselevel[0] == "c" else "",
            self.releaselevel[0],
            self.serial,
        ),
        "",
    )[self.releaselevel == "final"]
def __str__(self):
    return "{} {} / {}".format(__name__, self.__version__, __version_time__)
def __repr__(self):
    return "{}.{}({})".format(
        __name__,
        type(self).__name__,
        ", ".join("{}={!r}".format(*nv) for nv in zip(self._fields, self)),
    )

写在最后

如果有时间可以看看,python与tensorflow对应的版本
https://gitcode.net/mirrors/fo40225/tensorflow-windows-wheel/#tensorflow-windows-wheel

如果还是有其他问题,请耐心看错误提示。实在解决不了,就请留言吧,我们一起解决。

安装完后

(tf1) C:\Users\Administrator>conda list

packages in environment at G:\Anaconda3\envs\tf1:

Name Version Build Channel

bleach 1.5.0 pypi_0 pypi
certifi 2016.2.28 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
colorama 0.3.9 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
dataclasses 0.8 pypi_0 pypi
decorator 4.1.2 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
entrypoints 0.2.3 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
enum34 1.1.10 pypi_0 pypi
html5lib 0.9999999 pypi_0 pypi
icu 57.1 vc14_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
importlib-metadata 4.8.3 pypi_0 pypi
ipykernel 4.6.1 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
ipython 6.1.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
ipython_genutils 0.2.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
ipywidgets 6.0.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
jedi 0.10.2 py36_2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
jinja2 2.9.6 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
jpeg 9b vc14_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
jsonschema 2.6.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
jupyter 1.0.0 py36_3 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
jupyter_client 5.1.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
jupyter_console 5.2.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
jupyter_core 4.3.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
libpng 1.6.30 vc14_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
markdown 3.3.7 pypi_0 pypi
markupsafe 1.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
mistune 0.7.4 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
nbconvert 5.2.1 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
nbformat 4.4.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
notebook 5.0.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
numpy 1.19.5 pypi_0 pypi
openssl 1.0.2l vc14_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pandocfilters 1.4.2 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
path.py 10.3.1 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pickleshare 0.7.4 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pip 9.0.1 py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
prompt_toolkit 1.0.15 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
protobuf 3.19.6 pypi_0 pypi
pygments 2.2.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pyqt 5.6.0 py36_2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
python 3.6.0 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
python-dateutil 2.6.1 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pyzmq 16.0.2 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
qt 5.6.2 vc14_6 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
qtconsole 4.3.1 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
setuptools 36.4.0 py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
simplegeneric 0.8.1 py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
sip 4.18 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
six 1.16.0 pypi_0 pypi
tensorflow 1.4.0 pypi_0 pypi
tensorflow-tensorboard 0.4.0 pypi_0 pypi
testpath 0.3.1 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tornado 4.5.2 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
traitlets 4.3.2 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
typing-extensions 4.1.1 pypi_0 pypi
vc 14 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
vs2015_runtime 14.0.25420 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
wcwidth 0.1.7 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
werkzeug 2.0.3 pypi_0 pypi
wheel 0.29.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
widgetsnbextension 3.0.2 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
wincertstore 0.2 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
zipp 3.6.0 pypi_0 pypi
zlib 1.2.11 vc14_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值