Detectron2安装报错问题(本地cuda)

  • Post author:
  • Post category:其他


在安装Detectron2遇到了困难,如此报错:

Could not build wheels for detection2,which is required to install pyproject.toml-based projects

或者是:

detectron2 RuntimeError: Error compiling objects for extension

或者是:

This is an issue with the package mentioned above, not pip.

排除版本问题:

首先去官方说明查看detection2要求:


Installation — detectron2 0.6 documentation

简而言之:

①使用macOS或是Linux操作系统,且python版本≥3.7

②pytorch版本≥1.8,且安装对应版本的torchvision以及cuda

③若需要可安装opencv

④gcc与g++版本≥5.4,安装可以看别人的教程,注意更改默认版本

【仅供参考】本人系统Ubuntu20.04,其它版本:

①python = 3.7.0

②torch = 1.12.0,torchvision = 0.13.0,cuda = 10.2

③gcc&g++ = 5.4

问题解决:

①检查.bashrc

sudo gedit ~/.bashrc

②找到环境变量

可以看到我调用的本地cuda有问题,我安装的pytorch是cuda10.2版本的,那我就需要把路径改为正常路径(cuda-10.2),修改上述四个含有cuda-11.6的内容

③修改完保存关闭,并使更新立即生效

source ~/.bashrc

④查看当前使用的cuda版本

nvcc --version

如果显示为更换后的版本,即代表成功

⑤执行detectron安装命令

python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'

⑥successfully,问题解决

另外,本文只针对本地cuda,如若使用pytorch自带cuda,请参考本站其他内容



版权声明:本文为qq_50156360原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。