Anaconda虚拟环境安装Tensorflow-gpu 1.15

Anaconda虚拟环境安装Tensorflow-gpu 1.15

前言:
因为华为昇腾对Tensorflow暂时只支持1.15版本,所有需要安装一个,并且不能对其他的环境产生影响!

1. 新建虚拟环境
conda create -n hiascend_tensorflow python=3.7.5

2. 激活虚拟环境
conda activate hiascend_tensorflow

3. Anaconda换源
由于服务器在国外,所以更新下载很慢,建议换源到国内镜像源,在cmd控制台或者powershell下输入命令即可,选择一个镜像源。

//清华anaconda镜像:
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.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
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/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes

//中科大anaconda镜像:
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/
conda config --set show_channel_urls yes

4. 安装Tensorflow-gpu1.15
首先,查看官网,tensorflow1.15对应的cuda 和cudnn的版本:
在这里插入图片描述
考虑pytorch可以直接安装cuda和cudnn,就先安装了pytorch:
conda install pytorch1.2.0 torchvision0.4.0 cudatoolkit=10.0 -c pytorch

附加:
1、上面命令行可在pytorch官网上,根据需要安装的具体版本查找,copy过来即可;
2、上面所述的创建虚拟环境还可以使用以下途径:假如你有环境A,你只是需要尝试新建一个类似的虚拟环境B安装某一个模块,这个时候你就可以输入:
conda create -n B–clone A

验证:
python
import torch
torch.cuda.is_available()
若返回TRUE,则安装成功
在这里插入图片描述

然后直接安装tensorflow-gpu1.15:
conda install tensorflow_gpu==1.15.0
在这里插入图片描述
注意:
安装过程中发现cudnn安装的是7.6版本,和官网上的7.4不一致。

网上找到其他安装方式,未安装pytorch,直接安装的tensorflow:
pip install tensorflow-gpu==1.15
conda install cudatoolkit=10.0
conda install cudnn=7.6
没有尝试,以后有需要可以试试。

验证tensorflow:
import tensorflow as tf
a=tf.test.is_built_with_cuda()
b=tf.test.is_gpu_available(cuda_only=False,min_cuda_compute_capability=None)
print(a)
print(b)
​ 如果都是TRUE安装成功。
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值