700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > anaconda + pytorch 配置 CPU版和GPU版

anaconda + pytorch 配置 CPU版和GPU版

时间:2023-02-22 21:03:43

相关推荐

anaconda + pytorch 配置 CPU版和GPU版

配置国内源

conda config --add channels https://mirrors.tuna./anaconda/pkgs/free/conda config --add channels https://mirrors.tuna./anaconda/pkgs/main/# 配置国内源,安装PyTorch用conda config --add channels https://mirrors.tuna./anaconda/cloud/pytorch/conda config --add channels https://mirrors.tuna./anaconda/cloud/conda-forge/conda config --set show_channel_urls yes

# 删除所有channelsconda remove-key channels# 删除指定channelsconda remove channels $name

创建环境

conda create -n pytorch python=3.7

进入pytorch环境

conda activate pytorch

自动配置

GPU

在porch官网,选择配置。

注意1:(GPU)有Nvidia的显卡才能选择CUDA,

注意2:使用国内镜像要省略命令 -c pytorch -c nvidia

conda install pytorch torchvision torchaudio pytorch-cuda=11.6

或者(巨慢)

# 指定一个pytorch版本 conda install pytorch=1.12.0

CUP

# cpu最新版本pip install torch torchvision torchaudio -i https://pypi.tuna./simple

指定版本下载

pip install torch==版本号 torchvision==版本号 torchaudio==版本号 -i https://pypi.tuna./simple

手动配置GPU

在cuda的文档中下在对应版本的cuda+torch+torch+torchvision+torchaudio

例如:cuda11.6版的torch1.12.0、python3.7、windows,与之相匹配的是

cuda11.6版的torchaudio0.12.0、python3.7、windows,

cuda11.6版的torchvision0.13.0、python3.7、windows

手动安装

# 进入pytorch环境打开文件下载目录(pytorch) PS C:\Users\name> cd 'C:\Download\'# 安装 cu116 和 torch-1.12.0(pytorch) PS C:\Download> pip install torch==1.12.0 -i https://pypi.tuna./simple(pytorch) PS C:\Download> pip install .\torch-1.12.0+cu116-cp37-cp37m-win_amd64.whl# 安装torchaudio和torchvision(pytorch) PS C:\Download> pip install .\torchaudio-0.12.0+cu116-cp37-cp37m-win_amd64.whl(pytorch) PS C:\Download> pip install .\torchvision-0.13.0+cu116-cp37-cp37m-win_amd64.whl

测试

GPU

CUP

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。