Python 如何修复这些TensorFlow错误?(您的CPU支持该TensorFlow二进制文件未编译使用的指令:AVX2 FMA)

Python 如何修复这些TensorFlow错误?(您的CPU支持该TensorFlow二进制文件未编译使用的指令:AVX2 FMA),python,tensorflow,pycharm,Python,Tensorflow,Pycharm,我是TensorFlow的新手,今天我尝试安装它并在PyCharm中运行。我使用了我在网上找到的普通“pip3安装TensorFlow”。当我在PyCharm中导入TensorFlow时,我没有得到任何导入错误,但是我无法让我的示例代码正常运行有人知道我如何解决这个问题吗,或者有任何关于TensorFlow的非常好的完整教程吗? 顺便说一下,我正在macOS Catalina上使用MacBook Pro,并运行Python 3.7.4。我对使用PyCharm也很陌生 代码 输出 /Users/a

我是TensorFlow的新手,今天我尝试安装它并在PyCharm中运行。我使用了我在网上找到的普通“pip3安装TensorFlow”。当我在PyCharm中导入TensorFlow时,我没有得到任何导入错误,但是我无法让我的示例代码正常运行有人知道我如何解决这个问题吗,或者有任何关于TensorFlow的非常好的完整教程吗?

顺便说一下,我正在macOS Catalina上使用MacBook Pro,并运行Python 3.7.4。我对使用PyCharm也很陌生

代码 输出
/Users/anttesoriero/PycharmProjects/TensorTest/venv/bin/python/Users/anttesoriero/PycharmProjects/TensorTest/venv/main.py
2019-10-31 22:06:28.027494:I tensorflow/core/platform/cpu\u feature\u guard.cc:142]您的cpu支持该tensorflow二进制文件未编译为使用的指令:AVX2 FMA
2019-10-31 22:06: 28.052950:I TysFrace/编译器/ XLA/Service / Service .CC:168)XLA服务0x7F9CA1B4FA30在平台主机上执行计算。设备:
2019-10-31 22:06:28.052970:I tensorflow/compiler/xla/service/service.cc:175]StreamExecutor设备(0):主机,默认版本
回溯(最近一次呼叫最后一次):
文件“/Users/anttesoriero/PycharmProjects/TensorTest/venv/main.py”,第13行,在
sess=tf.Session()
AttributeError:模块“tensorflow”没有属性“Session”
进程已完成,退出代码为1
我还将在下面附上我所有代码和输出的屏幕截图。

您可能正在使用Tensorflow-2,并且您的代码仅与Tensorflow-1兼容,因为tf-2中没有这样的会话

您需要从tf-2切换到tf-1才能运行代码

关于此信息-

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

这只是一个警告,不是一个错误,这意味着当您通过编译二进制文件安装TensorFlow而不是像使用
pip那样安装预编译的TensorFlow时,您将获得性能提升。请添加您正在使用的TensorFlow版本。
/Users/anttesoriero/PycharmProjects/TensorTest/venv/bin/python /Users/anttesoriero/PycharmProjects/TensorTest/venv/main.py
2019-10-31 22:06:28.027494: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-10-31 22:06:28.052950: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7f9ca1b4fa30 executing computations on platform Host. Devices:
2019-10-31 22:06:28.052970: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (0): Host, Default Version
Traceback (most recent call last):
  File "/Users/anttesoriero/PycharmProjects/TensorTest/venv/main.py", line 13, in <module>
    sess = tf.Session()
AttributeError: module 'tensorflow' has no attribute 'Session'

Process finished with exit code 1
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA