最新版mmdetection3.0环境配置详细版win11

本教程是在默认具有anaconda3的基础上,如果没有请自行搜索一下,很简单!

同时说明:本人显卡为30系列,因此cuda版本必须为11系列,我安装的cuda版本为11.8,选择对应的torch,以及对应的mmcv与mmdet很重要,不然后续的demo会报错!

1.创建环境以及环境启动

        使用终端进行创建虚拟环境用于mmdetection相关包的安装使用操作命令如下:

conda create -n openmmlab python=3.8

终端命令如图:

最新版mmdetection3.0环境配置详细版win11_第1张图片

 输入命令后按enter键即可运行,环境启动命令为:

conda create openmmlab

最新版mmdetection3.0环境配置详细版win11_第2张图片

 看到命令行前面的base=》openmmlab,成功启动环境,接下来需要在openmmlab里面进行环境安装。

2.安装pytorch的cuda版本

        安装torch之前需要查看cuda对应的版本,不然无法使用cuda进行加速,有关于cuda的安装请自行搜索。查看cuda版本的命令:

nvidia-smi

结果如下图所示:

最新版mmdetection3.0环境配置详细版win11_第3张图片

 右上角cuda version即为版本,我的cuda是11.8

下一步便是去torch官网找到和cuda相关的torch下载命令

官网地址:https://pytorch.org/get-started/previous-versions/

最新版mmdetection3.0环境配置详细版win11_第4张图片

 此时不要急于下载,由于pytorch的源地址在国外,由于网络问题会下载特别慢,因此建议将pip与conda进行换源。

conda换源方式如下:

在"C:\Users\DELL\"地址下如有存在.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

pip换源方式比较简单只需在终端输入如下内容:

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

随后便可以进行下载,复制标黄的命令行:

conda install pytorch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 pytorch-cuda=11.8 -c pytorch -c nvidia

经过换国内源后,下载速度变快很多,大概需要4、5分钟既可完成。

3.安装mmcv

mmcv是openmmlab框架的底层,同样是基于pytorch的,但再使用openmmlab的开源项目时需要先安装mmcv,安装mmcv先查询应该安装什么版本,因为torch安装2.0.0,mmcv安装2.0.0即可,安装命令如下:

在终端一句一句执行即可

pip install openmim
mim install mmcv==2.0.0

到此为之mmcv以及安装完成,查看是否安装成功,在终端输入pip list

截取一部分的结果如下:

最新版mmdetection3.0环境配置详细版win11_第5张图片

 可以看到存在mmcv。

4.安装mmdet

第一步先把mmdetection项目clone到本地,不推荐git方法,git网络不稳定,本人没有好的解决办法,进入github搜索mmdetection项目zip到本地,解压到"C:\Users\DELL\"地址下。

在mmdetection项目的相关包中存在一个问题,即pip无法安装pycocotools安装包,因此需要使用下述命令安装pycocotools:

conda install pycocotools -c conda-forge

上述步骤完成后,可以在终端进入项目文件夹:

 进入项目文件夹后便可安装所需包:

pip install -v -e .

总结

        上述过程是配置mmdetection环境的所有步骤,由于本人属于小白阶段,如有问题请指出,定虚心请教。

手打几行代码验证安装是否成功在下一个文章,大家请移步观看!

你可能感兴趣的:(python,pytorch,深度学习,conda)