一、新建环境
conda create -n detectron2 python=3.7.3
conda activate detectron2
二、 安装Pytorch
我的CUDA版本是11.7
pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu117
三、安装需要的包
# 安装fvcore pip install fvcore==0.1.1.post20200716 # 安装pycocotools pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
四、安装detectron2
刚开始我是按照https://zhuanlan.zhihu.com/p/345472198进行
最后一步有两个问题:
(1)不需要cd detectron2不然会报错
(2)排除(1)问题后又出现了@torch.compiler.disable - AttributeError: module 'torch' has no attribute 'compiler'的问题
按照上述过程会在当前路径出现./detectron2文件夹,报错之后https://github.com/facebookresearch/detectron2/issues/5268给了解决办法
首先要将原来的detectron2删掉,然后
pip install 'git+https://github.com/facebookresearch/detectron2.git@v0.6'
就解决啦!