detectron2安装方法

本文提供了两种安装Detectron2的方法,一种是从源码构建,另一种是预编译安装(仅限Linux)。对于已知CUDA和PyTorch版本的用户,推荐使用预编译安装方法,该方法更快速且不易出错。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装detectron2

安装detectron2的方法,官方教程:Installation — detectron2 0.6 documentation

第一种方法:Build Detectron2 from Source

官方大大的源码:

python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
# (add --user if you don't have permission)

# Or, to install it from a local clone:
git clone https://github.com/facebookresearch/detectron2.git
python -m pip install -e detectron2

# On macOS, you may need to prepend the above commands with a few environment variables:
CC=clang CXX=clang++ ARCHFLAGS="-arch x86_64" python -m pip install ...

注意:如果采用先下载detectron2,再安装的方法,下载之后不要  cd detectron2,否则会出现找不到“step.py”的错误。

我的环境是CUDA:11.6, pytorch:1.10.2

采用第一种方式安装,会出现CUDA与torch版本不匹配。报错如下:

第二种方法:Install Pre-Built Detectron2 (Linux only)

知道自己的CUDA版本和torch版本后,采用第二种方法更快,而且不易出错,我就是采用的这种方法安装完成的。

我的环境是CUDA:11.6, pytorch:1.10.2,我选择的是CUDA==10.2, torch==1.10。

 成功!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值