下载pychram,anaconda 配置清华源 构建虚拟环境
安装cuda-pytorch
1软件安装包
链接:https://pan.baidu.com/s/1WRl6bcG731TXQ-f3zQnhkg?pwd=onz4 提取码:onz4
2配置清华源
在C:\Users\1目录下生成.condarc文件
将以下复制到空白的.condarc文件中
channels: 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
3创建环境
打开anaconda中的Prompt
输入下列代码 其中huanjingming为你设置的环境名 python版本为任意设置建议3.6
conda create --name huanjingming python=3.6
显示安装后 输入y 生成环境
接下来激活创建的环境输入代码 conda activate 加上你创建的环境名
conda activate huanjingming
左侧显示出环境名,说明进入了环境
cuda安装
由于cuda安装比较复杂,同时直接安装最新cuda会出现不兼容问题 而旧版cuda可能在各种源中找不到 所以我选择分别安装对应版本的cuda。
输入代码
conda install cudnn
conda install cudatoolkit=10.2
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple torch===1.6.0
torchvision===0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
或者直接配置11.6
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1
安装完 在该环境下 打开python 输入代码查看cuda是否可用
conda remove --name=yolov9 --all
import torch
torch.cuda.is_available