在Anaconda中配置YOLOv3-Pytorch-GPU环境配置
cuda-10.0
cudnn-7.64
torch-1.2
torchvision-0.40
1 Anaconda创建一个虚拟环境(名为pytorch)
conda create -n pytorch python=3.6
2 激活pytorch虚拟环境
conda activate pytorch
3 在虚拟环境中安装cuda10.0
终端输入
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 --set show_channel_urls yes
因为conda的默认源速度慢且没有cuda版本,因此需要添加国内清华或者中科大的源
conda install cudatoolkit=10.0 -n pytorch -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
4 在虚拟环境中安装cuda对应的cudnn版本7.64
conda install cudnn=7.6.4 -n pytorch -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
检查cuda和cudnn是否安装成功
为这里的cuda是安装在虚拟环境中的,并非直接安装在系统中。所以,在对应文件夹中无法找到对应文件,自然也无法使用ncvv -V/ncvv --version来查看版本。
应该先访问pytorch,再调用cuda、cudnn。具体操作如下:
在pytorch虚拟环境中输入“python”进入python环境
python
查看cuda版本
>>>import torch
>>>print(torch.version.cuda)
查看cudnn版本
>>>import torch
>>>print(torch.backends.cudnn.version())
5 在虚拟环境中安装torch-1.2、torchvision-0.40
conda install pytorch==1.2.0 torchvision==0.4.0
6 在虚拟环境中安装其他所需包
conda install scipy==1.2.1
conda install numpy==1.17.0
conda install matplotlib==3.1.2
conda install opencv_python==4.1.2.30
conda install tqdm==4.60.0
conda install Pillow==8.2.0
conda install h5py==2.10.0
7 训练时查看GPU-Util(GPU使用率)
nvidia-smi