首页自学conda部署与物理机不同的cuda版本,一行命令部署pytroch或TensorFlow环境

conda部署与物理机不同的cuda版本,一行命令部署pytroch或TensorFlow环境

adminadmin时间2024-06-28 18:49:42分类自学浏览49


多套AI机器学习框架最佳的实践方法就是使用conda来管理不同的虚拟环境,以前用pip喜欢手动下载手动安装,什么cuda cudnn,各种版本相互依赖,conda就专治这个。但由于习惯,在使用conda之后还习惯性地在conda中做pip安装cuda cudnn,直到后来完全了解了conda install能够根据显卡型号和python版本和要安装的ai框架版本自动解决依赖问题。

1、安装conda,这个似乎没有太多强制版本的,可直接从官网下载最新。

conda下载地址

https://docs.conda.io/en/latest/miniconda.html有时用迅雷等下载工具比浏览器快一些

安装完成后以管理员方式运行 conda3



2、配置源,这主要是配置国内源达到下载加速

以管理员方式运行 conda3后 在conda的窗口上运行命令

conda config --set show_channel_urls yes

之后会在 C:\Users\(电脑用户名)会生成一个配置文件.condarc 打开编辑


channels:
 - defaults
show_channel_urls: true
default_channels:
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
 conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
 msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
 bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
 menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
 pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
 pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
 simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
编辑保存后,运行conda clean –i

以下是两种机器学习框架的安装过程,tf已经实践过,pytroch 尚未实践,根据个人了解补充。

安装tensorflow-gpu==1.15 

退出之前的环境,conda deactivate

conda create -n tf15 python=3.7 #创建环境
activate tf15 #进入环境
conda install tensorflow-gpu=1.15.0#安装tf gpu版 会自动安装对应的cuda和cudnn
这里tf1.x的python版本不能高于3.7,如果创建了高于3.7的python安装会报错。

如果不指定版本,就不论python版本,全按最新。

现在tf已经出到2.2x了,少量代码会强制要求tf版本。

同时tf1.15之后,不再区分gpu和cpu,不再存在tensorflow-gpu这种名称了。


安装pytroch 

退出之前的环境,conda deactivate

官网查看

https://pytorch.org/get-started/locally/


conda create -n pytorchenv python=3.8.10
activate pytorchenv
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia



本文《conda部署与物理机不同的cuda版本,一行命令部署pytroch或TensorFlow环境》bushu/211.html

与《conda部署与物理机不同的cuda版本,一行命令部署pytroch或TensorFlow环境》

0
0
收藏0
永泰运(001228.SZ):拟将所持昊泰化工51%股权转让给汇隆石油

    未登录用户 回复需填写必要信息
    请先 登录 再评论,若不是会员请先 注册