PVTv2环境搭建

PVT2环境搭建

Prerequisites(条件)

  • Linux or macOS

  • Python 3.6+

  • PyTorch1.3+

  • CUDA 9.2+

  • GCC 5+

  • MMCV

进入自己的环境,例如我的是ZYL

conda activate ZYL  #激活环境

查看电脑的相关配置

使用cmd命令查看电脑的内存信息以及相关配置

msinfo32 # 查看相关信息

 然后获取相关的GPU信息,如果使用下面的命令错误就就需要在C盘查找nvidia-smi环境配置,然后cmd命令输入

nvidia-smi # 获取GPU信息

 

安装mmdetection环境

Pytorch安装包

conda install pytorch==1.8.0 torchvison==0.9.0 cudatoolkit=10.2 -c pytorch  #安装pytorch

或者分开安装

# 安装torch
pip install torch==1.8.0 -i https://mirrors.aliyun.com/pypi/simple/
# 安装torchvision
pip install torchvision==0.9.0 -i https://mirrors.aliyun.com/pypi/simple/

然后输入下面的命令安装完成后查看cuda的版本

nvcc -V #查看cuda的版本

(ZYL) dellgnode01:~$ nvcc -V Lnvcc: NVIDIA (R)cuda compiler driver copyright (c)2005-2019 NVIDIA Corporation'Built on wed oct_23_19:24:38__PDT_2019 Tcuda compilation tools, release 10.2,V10.2.89

如果出现nvcc' 不是内部或外部命令,也不是可运行的程序或批处理文件。就需要安装驱动,也可能是其他原因,请参考下面的文章:

https://blog.csdn.net/XieRuily/article/details/123670141

安装mmcv版本

安装形式:pip install mmcv-full -f https://downLoad.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/ index.html

pip install mmcv-full -f https://downLoad.openmmlab.com/mmcv/dist/cuda102/torch1.8.0/index.html

也可指定版本:

pip install mmcv-full==1.2.4  #稳定版本

克隆MMDetection

git clone https://github.com/open-mmLab/mmdetection.git  #克隆
cd mmdetection  #进入文件夹

安装构建要求,然后再安装MMDetection

pip install -r requirements/build.txt  #构建要求
pip install -v -e . # 或者"python setup.py develop"

查看MMDetection版本号

安装timm模块

pip install timm==0.4.12

ape安装

git clone https://github.com/NVIDIA/apex  #clone apex
cd apex  #进入文件夹
python setup.py install --cpp_ext --cuda_ext --user #

验证安装

新建一个.py文件,复制如下代码进行运行

from mmdet.apis import init_detector, inference_detector
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
# download the checkpoint from model zoo and put it in `checkpoints/` #url:http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cuda:0'
# init a detector
model = init_detector(config_file, checkpoint_file, device=device)
# inference the demo image
inference_detector(model, 'demo/demo.jpg')

安装完成apex会报错:

AttributeError: module 'torch.distributed' has no attribute '_all_gather_base'

 

 

 

 

 

posted @ 2023-03-08 22:04  Crown-V  阅读(236)  评论(0)    收藏  举报