深度学习环境搭建笔记(一):detectron2安装过程


✅💖⚠️▶️➡️🌿🍀🍄🌟⭐❄️✅💖⚠️▶️➡️🌿🍀🍄🌟⭐❄️✅💖⚠️▶️➡️🌿🍀🍄🌟⭐❄️✅💖⚠️

这篇博客是深度学习环境搭建笔记(一),主要介绍了在 cuda 10.2 环境下 detectron2 的安装过程,具体步骤如下:

  1. 安装 python:使用 conda create -n detectron python=3.7 命令创建名为 detectron 的虚拟环境并安装 Python 3.7。
  2. 安装 pycocotools:根据 Python 版本从 PyPI 下载对应的 pycocotools_windows 版本,如 pip install pycocotools_windows-2.0.0.2-cp37-cp37m-win_amd64.whl
  3. 安装 Torch 和 Torchvision:分别执行 pip install “torch-1.10.1+cu102-cp37-cp37m-win_amd64.whl”pip install “torchvision-0.11.2+cu102-cp37-cp37m-win_amd64.whl” 进行安装。
  4. 安装 fvcore:从 GitHub 下载链接 https://github.com/facebookresearch/fvcore 获取源码,进入 setup.py 所在目录,执行 python setup.py build --force develop 安装,安装后在 cmd 中输入 import fvcore 无报错即为成功。
  5. 安装 detectron2
    • 修改 pytorch 代码:按照官方文档对两个文件进行修改,一是将 {your evn path}\Lib\site-packages\torch\include\torch\csrc\jit\runtime\argumenta_spec.h 中的 static constexpr size_t DEPTH_LIMIT = 128; 改为 static const size_t DEPTH_LIMIT = 128;;二是将 {your evn path}\Lib\site-packages\torch\include\pybind11\cast.h 中的 explicit operator type&() { return *(this->value); } 改为 explicit operator type&() { return ((type)this->value); }
    • 修改 detectron2 代码:将 detectron2\detectron2\layers\csrc\deformable 文件夹下三个文件中的全部 AT_CHECK 替换为 TORCH_CHECK
  6. 开始安装:进入解压后 setup.py 的路径,执行 python setup.py build --force develop 完成 detectron2 的安装,安装完成后在 Python 环境中输入 import detectron2 验证安装成功。

第一步 安装python🌿

cuda 10.2 环境下 
  • conda create -n detectron python=3.7

第二步 安装pycocotools🌿

  • 下载对应的pycocotools-windows · PyPI根据python版本,然后pip安装
  • pip install pycocotools_windows-2.0.0.2-cp37-cp37m-win_amd64.whl

第三步 安装Torch和Torchvision🌿

  • pip install “torch-1.10.1+cu102-cp37-cp37m-win_amd64.whl”
  • pip install “torchvision-0.11.2+cu102-cp37-cp37m-win_amd64.whl”

第四步 安装fvcore🌿

下载链接:https://github.com/facebookresearch/fvcore 点击跳转.
然后cd到setup.py所在目录,用以下指令安装
python setup.py build --force develop
打开cmd输入 import fvcore 没报错即成功

第五步 安装detectron2🌿

在安装detectron2前需要先修改detectron2与pytorch的代码以保证顺利安装。
下载地址:https://github.com/conansherry/detectron2 点击跳转.
1)根据官方文档对pytorch进行如下修改(觉得难找可以下载Everything)

file1:
{your evn path}\Lib\site-packages\torch\include\torch\csrc\jit\argument_spec.h
example:
{C:\Miniconda3\envs\py36}\Lib\site-packages\torch\include\torch\csrc\jit\argument_spec.h(190)
   static constexpr size_t DEPTH_LIMIT = 128;
      change to -->
   static const size_t DEPTH_LIMIT = 128;
file2:
{your evn path}\Lib\site-packages\torch\include\pybind11\cast.h
example:
{C:\Miniconda3\envs\py36}\Lib\site-packages\torch\include\pybind11\cast.h(1449)
    explicit operator type&() { return *(this->value); }
      change to -->
   explicit operator type&() { return ((type)this->value); }

第一个文件的位置有变动为:{your evn path}\Lib\site-packages\torch\include\torch\csrc\jit\runtime\argumenta_spec.h

<font color='red'>2)</font>将detectron2\detectron2\layers\csrc\deformable 文件夹下三个文件中全部的 AT_CHECK 全部替换为 TORCH_CHECK

第六步 开始安装🌿

  • 进入解压后setup.py的路径
    cd detectron2
  • 安装
    python setup.py build --force develop

在这里插入图片描述

  • 验证
    在这里插入图片描述

✅💖⚠️▶️➡️🌿🍀🍄🌟⭐❄️✅💖⚠️▶️➡️🌿🍀🍄🌟⭐❄️✅💖⚠️▶️➡️🌿🍀🍄🌟⭐❄️✅💖⚠️

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ZZY_dl

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值