安装detectron2的报错1
ps:看来这个后面的可以不用看了
虽然使用后面的方法安装成功,但是最后打开项目运行时会报各种奇奇怪怪的错误
最终我根据这个教程安装成功,
并且对该文档的补充如下:
1:安装detectron2中的步骤1)修改文档时,第二个文档可以不用修改,有评论说新版完善了
如果没找到explicit operator type&() { return *(this->value); }
(D:\ProgramData\Anaconda3\envs\pytorch\Lib\site-packages\torch\include\pybind11\cast.h)
2、将detectron2\detectron2\layers\csrc\deformable 文件夹下三个文件中全部的 AT_CHECK 全部替换为 TORCH_CHECK,我的文件里没有AT_CHECK ,所以也没替换
3、跟着该文档的步骤就安装成功了
错误
我选择的安装方式
官方安装教程
link
# Or, to install it from a local clone:
git clone https://github.com/facebookresearch/detectron2.git
python -m pip install -e detectron2
在执行第二条指令时出错
环境说明
win10
cuda:11.6
torch:1.13.1
解决方案
这是报错的内容中编译失败的文件
5 errors detected in the compilation of "D:/code/textdetec/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cuda.cu".
nms_rotated_cuda.cu
找到图片目录中的文件
打开该文件并进行注释掉一部分
原文件
// Copyright (c) Facebook, Inc. and its affiliates.
#include <ATen/ATen.h>
#include <ATen/cuda/CUDAContext.h>
#include <c10/cuda/CUDAGuard.h>
#include <ATen/cuda/CUDAApplyUtils.cuh>
#ifdef WITH_CUDA
#include "../box_iou_rotated/box_iou_rotated_utils.h"
#endif
// TODO avoid this when pytorch supports "same directory" hipification
#ifdef WITH_HIP
#include "box_iou_rotated/box_iou_rotated_utils.h"
#endif
修改后的文件
// Copyright (c) Facebook, Inc. and its affiliates.
#include <ATen/ATen.h>
#include <ATen/cuda/CUDAContext.h>
#include <c10/cuda/CUDAGuard.h>
#include <ATen/cuda/CUDAApplyUtils.cuh>
/*#ifdef WITH_CUDA
#include "../box_iou_rotated/box_iou_rotated_utils.h"
#endif
// TODO avoid this when pytorch supports "same directory" hipification
#ifdef WITH_HIP
#include "box_iou_rotated/box_iou_rotated_utils.h"
#endif*/
#include "box_iou_rotated/box_iou_rotated_utils.h"
重新执行安装指令
python -m pip install -e detectron2