windows 安装tensorflow2(本地环境python3.9,pip20.2.3)

 使用 pip 安装 TensorFlow(参考:https://tensorflow.google.cn/install/pip

pip install --upgrade tensorflow

 

下载支持依赖(VC_redist.x86.exe)

        https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads

 测试安装是否成功

python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

 

缺少的dll 下载后放到 C:\Windows\System32\
        https://cn.dll-files.com/download/

 

Demo:

import tensorflow as tf

tf.compat.v1.disable_eager_execution()
message=tf.constant('welcome to zac first tf')

with tf.compat.v1.Session() as sess:
   print(sess.run(message).decode())

-----------虚拟环境运行
创建一个新的虚拟环境,方法是选择 Python 解释器并创建一个 .\venv 目录来存放它:
    python -m venv --system-site-packages .\venv
    
激活虚拟环境:
    .\venv\Scripts\activate
    
在不影响主机系统设置的情况下,在虚拟环境中安装软件包。首先升级 pip:
    pip install --upgrade pip
    pip list  # show packages installed within the virtual environment
    
之后退出虚拟环境:
    deactivate  # don't exit until you're done using TensorFlow 
   
   
------v1的一些函数
tf.compat.v1.disable_eager_execution()
tf.compat.v1.placeholder   
tf.compat.v1.Session()

 

 

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值