安装TF2 CPU
安装tensorflow2 CPU版,真的很简单,很简单。可还是折腾了一下午
官方给的安装方法
我是使用conda新建一个环境,建议python3.6,避免不必要的麻烦。
conda create --name tf2_1 python=3.6
conda activate tf2_1
安装适用于Visual Studio 2015、2017 和 2019 的 Microsoft Visual C++可再发行软件包。从 TensorFlow 2.1.0 版开始,此软件包需要 msvcp140_1.dll 文件(旧版可再发行软件包可能不提供此文件)。 下载地址
记住是这个2015-2019通用版本。
pip install tensroflow-cpu
配置源,或者科学上网来加快速度。
最后测试一下
import tensorflow as tf
A = tf.constant([[1, 2], [3, 4]])
B = tf.constant([[5, 6], [7, 8]])
C = tf.matmul(A, B)
print(C)
中间那个提示是指令集问题,问题不大。
Failed to load the native TensorFlow runtime.
有人会碰到DLL加载错误,把Visual Studio 2015、2017 和 2019 的 Microsoft Visual C++装上就好了。