![Tensorflow 安装问题](https://linux22.com/image/999943/Tensorflow%20%E5%AE%89%E8%A3%85%E9%97%AE%E9%A2%98.png)
我安装了 Tensorflow,到目前为止运行良好。但是,当我执行代码时,它显示以下内容
2017-05-07 12:35:10.449884: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-07 12:35:10.449909: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-07 12:35:10.449919: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-05-07 12:35:10.449927: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-07 12:35:10.449934: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
我尝试了很多不同的解决方案,但都没有用。有一个使用 Bazel 的解决方案,但我想我没用过这个应用。我该如何解决这个问题?
┌─╼ [~]
└────╼ python3 test.py
2017-05-07 13:23:04.148596: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-07 13:23:04.148624: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-07 13:23:04.148629: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-05-07 13:23:04.148633: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-07 13:23:04.148637: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
Tensor("add:0", shape=(), dtype=int32)
5
┌─╼ [~]
└────╼ export TF_CPP_MIN_LOG_LEVEL=3
┌─╼ [~]
└────╼ python3 test.py
Tensor("add:0", shape=(), dtype=int32)
5
但是,如果我关闭终端并再次打开它,我会得到同样的错误。如何让这个伟大的解决方案export TF_CPP_MIN_LOG_LEVEL=3
永久有效?
提前致谢!
答案1
类似的问题已发布在堆栈溢出。您可以忽略这些警告。如果它们让您烦恼,您可以使用 来掩盖它们os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
,例如:
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
print('TensorFlow version: {0}'.format(tf.__version__))
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))