error: command ‘D:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.6\\bin\\nvcc.exe‘ failed

文章讲述了作者在安装detectron2时遇到的编译错误,涉及CUDA版本兼容问题和AT_CHECK到TORCH_CHECK的替换。通过注释部分代码和按照特定步骤,作者成功解决了安装过程中的问题。
摘要由CSDN通过智能技术生成

安装detectron2的报错1

ps:看来这个后面的可以不用看了

虽然使用后面的方法安装成功,但是最后打开项目运行时会报各种奇奇怪怪的错误
最终我根据这个教程安装成功,

link

并且对该文档的补充如下:

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

在这里插入图片描述

参考文档;

link

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值