Win10配置YOLO目标检测Pytorch环境

该博客详细介绍了在Windows10系统上,如何安装CUDA11.0、CuDNN,并配合Pytorch进行配置。首先,从官方链接下载对应显卡版本的CUDA和CuDNN,然后将库文件添加到CUDA路径。接着,安装Anaconda并创建虚拟环境,通过conda命令安装Pytorch,可以选择不同版本。此外,还提供了conda和pip命令安装OpenCV及pycocotools的步骤,并给出了验证安装成功的Python代码。文章最后提到了使用清华和阿里云镜像加速conda和pip安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

系统环境:Win10+显卡3090

安装cuda和cudnn:

Windows10系统pytorch、cuda11.0、cuDNN安装

注意事项:

1.查看显卡版本后下载对应版本的cuda和cudnn,链接如下:

cuda下载:https://developer.nvidia.com/cuda-toolkit-archive

cudnn下载:https://developer.nvidia.com/rdp/cudnn-archive

2.安装好cuda后,安装cudnn即将下载的压缩包里的lib,include,bin文件添加到cuda对应路径下。

注意,一台电脑可以安装多个版本的cuda,版本之间的切换只需要将系统环境变量对应版本的路径前置即可。同时,执行Pytorch官方的conda安装命令,也可以在anaconda创建的虚拟环境中搭建pytorch所需对应版本的cuda和cudnn。另外,可以使用conda命令在虚拟环境中单独安装所需cuda和cudnn:例如conda install cudatoolkit=11.2 cudnn=8.1

安装Anaconda:

win10中安装Anaconda

安装Pytorch:

Pytorch官网:https://pytorch.org/

创建虚拟环境:conda create -n env_name python=3.9

注意事项:除非自己有编译需求,否则无需先安装cuda和cudnn,根据官网,只需一条命令即可。因此可以任意选择需要的Pytorch版本,不一定要安装显卡驱动对应的cuda版本,因为Pytorch官网conda命令安装pytorch时会在虚拟环境中重新配置对应的cuda和cudnn。

conda添加清华、阿里源:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/main

conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/r

conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/msys2

conda config --set show_channel_urls yes

验证pytorch、cuda、cudnn:

python
import torch
import torchvision
print(torch.__version__)
print(torchvision.__version__)
print(torch.cuda.is_available())

torch.version.cuda

torch.backends.cudnn.is_available()

torch.backends.cudnn.version()

安装Opencv:

conda install -c conda-forge opencv

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python

pip添加清华源:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

安装pycocotools:

pip install cython

(Linux)pip install pycocotools或者(Win)pip install pycocotools-win

Windows和Linux端简单安装pycocotools方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值