TensorFlow 安装后提示加载运行时失败怎么办?

297 阅读1分钟

TensorFlow 可以正常安装,但安装后提示加载运行时失败:

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

这个问题折磨了我,可能还会再折磨许多人,所以我把解决方法写在这里。

产生这个问题的原因是,你的机器的 CPU 太老了,不支持 AVX 指令集,而 TensorFlow 1.6 及以后的官方版本都使用了 AVX 来编译,所以都会报告 Failed to load the native TensorFlow runtime.

然后如果你想安装 TensorFlow 1.5.x 及更老的版本的话,可能又会遇到兼容性问题。 所以最佳解决方案是,到这里: github.com/fo40225/ten…

下载适用于你的 Python 版本的、 SSE 编译的 TensorFlow ,目录后缀都是 sse2

如果之前安装过 tensorflow 还没卸载,记得先卸载:

pip uninstall tensorflow

然后用 pip 本地安装,例如:

pip install tensorflow-2.0.0-cp37-cp37m-win_amd64.whl