detectron2安装(亲测好用)

detectron2安装(亲测好用)

先码一下服务器配置:

  • NVIDIA GeForce RTX 3090
  • CUDA Version: 12.0

官网配置要求:

  • Linux or macOS with Python ≥ 3.7
  • PyTorch ≥ 1.8 and torchvision that matches the PyTorch installation. Install them together at pytorch.org to make sure of this
  • OpenCV is optional but needed by demo and visualization

bpbreid 要引入 functools 包,需要 python>3.8

所以:
创建环境:

conda create --name detectron python=3.8
conda activate detectron

安装pytorch:
cuda安11.3有报错:

RuntimeError:
    The detected CUDA version (10.1) mismatches the version that was used to compile
    PyTorch (11.3). Please make sure to use the same CUDA versions.

所以 cudatoolkit=10.1

# conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch
pip install torch==1.8.1+cu101 torchvision==0.9.1+cu101 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

接着验证cuda的可用性。

安装opencv:

pip install opencv-python

安装cpython:

pip install cython

安装pycocotools:

pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
# 下面的也可以
pip install pycocotools

安装detectron2:

  1. git clone
git clone https://github.com/facebookresearch/detectron2.git
  1. 由于师姐的服务器的卡是3090,直接安装 detectron2 会报错,需要对 detectron2 的 setup.py 进行修改。
    • detectron2 的位置:/home/huilin/detectron2
    • In the last line of setup.py, you change from cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension}, to cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension.with_options(use_ninja=False)},
  2. 安装
python -m pip install -e detectron2

我按上面的步骤来,装了2次都成功了,应该还是比较可行的

评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值