1 TensorFlow2.0开发环境安装与配置

1 TensorFlow2.0开发环境安装与配置

这里是window10系统下运行NVIDIA显卡的计算机上的TensorFlow2.0的基于Anaconda的安装,利用conda新建虚拟环境,在新的虚拟环境中进行开发

1.1 conda环境

安装好Anaconda后就可以在cmd中使用conda指令

  1. 新建conda环境:conda create -n env_name
  2. 激活conda环境:conda activate env_name
  3. 退出conda环境:conda deactivate
  4. 安装python包:conda install package_name
  5. 卸载python包:conda uninstall package_name
  6. 查看已安装python包:conda list -n env_name
1.1.1 新建TF2环境与配置

新建虚拟环境

conda create -n TF2 python=3.7    
#新建环境名TF2,使用python版本为3.7

进入环境

conda activate TF2

安装GPU版本支持,检查NVIDIA显卡驱动
安装cudatookit与cudnn包

conda install cudatoolkit=10.0 cudnn

安装tensorflow2.0,使用清华源下载

pip install tensorflow==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

1.2 测试

在conda环境中使用Spyder来写代码
即在虚拟环境中用Spyder,或者是Spyder中用虚拟环境中的库,则需要在虚拟环境中安装并启动
激活之前创建的环境,安装spyder并启动

conda install spyder
#创建一个使用TF2环境的spyder
spyder

测试代码

import tensorflow as tf
version = tf.__version__
gpu_ok = tf.test.is_gpu_available()
print("tf version:",version,"\nuse GPU",gpu_ok)

正确输出

tf version: 2.0.0
use GPU True
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值