Win10下TensorFlow2.0安装CPU版和GPU版

下面这篇博客是我所见最简单的安装TensorFlow2.0的方法没有之一!我光搭建这个环境瞎搞了5天都没整明白,之前看到这篇博客还不以为然,但是用过之后真香啊!感谢原博主“小宋是呢”。

正式开始前先说明一下,TensorFlow、Python、CUDA、cudnn各个包之间对于版本要求比较高,如果某个包版本不合适就没法运行,下面这篇blog省去了选择版本的麻烦,几行命令行代码全搞定,下面是blog链接,但请结合我的补充一起看:

『TensorFlow2.0正式版』极简安装TF2.0正式版(CPU&GPU)教程

图1

在执行图1步骤之前,先将国内的镜像源添加进环境中,原博主只在代码中声明了一个镜像路径,感觉还有些慢,参考了如下博客,可以直接看我整理的,我删除一些不必要的。对原博主表示感谢。

Anaconda 国内镜像源整理

清华源:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

中科大源:

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/

只需在终端(命令行)中切换至TF_2C环境中(如图2),整段代码复制进去,前面运行完再回车即可,如此添加清华源与中科大源。

图2

PS:前面(TF_2C)表示处于此环境中

接下来便可以继续按照小宋是呢的博客操作,直到测试版本,可以不必创建demo.py,在所创建环境TF_2C中输入python,然后复制代码即可。如图3

图3

如上图表明CPU版安装完成,GPU版类似。

关于运行线性拟合的测试程序可以参考我另外一篇博客用pycharm在TensorFlow2.0环境下运行线性拟合测试程序。

用pycharm在TensorFlow2.0环境下运行程序

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值