ubuntu利用conda创建虚拟环境,并安装cuda,cudnn,tensorflow

1.安装Anaconda:

下载地址:https://www.anaconda.com/products/individual
Windows安装:
直接双击exe文件,下一步,直到结束,注意安装路劲中避免空格,否则后面使用过程中会发出警告
安装完成后配置环境变量:
D:\ProgramFiles\Anaconda3
D:\ProgramFiles\Anaconda3\Scripts
D:\ProgramFiles\Anaconda3\Library\bin
Linux安装:
./xxx.sh

2.安装NVIDIA驱动:

linux查看NVIDIA驱动:
lspci |grep VGA
查看显卡具体型号:http://pci-ids.ucw.cz/mods/PC/10de?action=help?help=pci
CUDA版本与显卡驱动版本匹配查询:https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html/
在这里插入图片描述
NVIDIA驱动下载地址:https://www.geforce.cn/drivers
根据自己的显卡型号以及操作系统下载对应驱动

3.conda安装仓库

科大源

conda config --add(remove) channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add(remove) channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

清华源

conda config --add(remove) channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

切换回conda默认的源

conda config --remove-key channels

4.创建虚拟环境

conda create -n your_env_name python=3.6,若不写依赖项python的版本号,则默认安装最新的python包

5.激活虚拟环境

conda activate your_env_name,只有激活虚拟环境,你才能使用虚拟环境

6.安装cuda和cudnn

查看tensorflow、cuda、cudnn的官方地址:https://tensorflow.google.cn/install/source#tested_build_configurations
tensorflow、cuda和cudnn对照表如下:
在这里插入图片描述

5.1 安装cuda

conda install cudatoolkit=10.1

5.2 安装cudnn

conda install cudnn=7.6.5

7.安装tensorflow-gpu

pip在线使用阿里源安装
pip install -i https://mirrors.aliyun.com/pypi/simple tensorflow-gpu==2.1

Linux下pip永久使用阿里源:
cd $HOME
vi .pip/pip.conf

[global]
index-url = https://mirrors.aliyun.com/pypi/simple

Windows下pip永久使用阿里源:
直接在user目录中创建一个pip目录,如:C:\Users\用户名\pip,新建文件pip.ini,内容如下

[global]
index-url = https://mirrors.aliyun.com/pypi/simple
  • 1
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值