经过挣扎,我安装好了tensorflow,但是运行还是出现警告:

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

就是说我不能完全使用AVX2

原来代码:

import tensorflow as tf  # 导入TensorFlow的包

s= tf.constant([[1, 2, 3], [4, 5, 6]]) # 这里定义了一个Tensor
print("s", s)

解决方案:忽略警告就好了,于是我们在原来代码加入新的部分:

import os 

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

所以新的代码为:

import tensorflow as tf  # 导入TensorFlow的包
import os

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
s= tf.constant([[1, 2, 3], [4, 5, 6]]) # 这里定义了一个Tensor
print("s", s)