当前位置: 首页 > news >正文

Windows11 -MASKRCNN-部署测试

文章目录

  • Detectron2环境配置
    • 搭建python 环境
    • 安装Cuda \CUDNN 、PyTorch、 torchvision、cudatoolkit
      • 1、Cuda \CUDNN
      • 2、 PyTorch、 torchvision、cudatoolkit
        • 进入python测试:
        • 错误信息
      • 3、detectron2环境
        • 在安装detecteron中,遇到报错:
        • 编译的时候failed with exit status 1错误
    • 运行demo.py

Detectron2环境配置

需要配置好相应版本的NVIDIA驱动、CUDA、Pytorch、visual studio,visual stdio2019是为了配置gcc g++的。
配置pytorch的链接.
配置CUDA的链接
在这里插入图片描述

可参考项目中的官方安装说明

搭建python 环境

conda create -n detectron2 python
conda activate detectron2

安装Cuda \CUDNN 、PyTorch、 torchvision、cudatoolkit

1、Cuda \CUDNN

可以查询自己的nvcc-v查询自己cuda版本,查看安装指南

2、 PyTorch、 torchvision、cudatoolkit

终端输入:

nvcc -V
得到输出结果,cuda版本为12.1

在这里插入图片描述

# CUDA 11.8
conda install pytorch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 pytorch-cuda=11.8 -c pytorch -c nvidia
# CUDA 12.1
conda install pytorch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 pytorch-cuda=12.1 -c pytorch -c nvidia
# CPU Only
conda install pytorch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 cpuonly -c pytorch
进入python测试:

import torch
import torchvision
torch.cuda.is_available()

在这里插入图片描述

错误信息

在这里插入图片描述
解决办法链接

Anaconda>DLLs,重启shell

3、detectron2环境

在此路径下,激活detectron2环境,输入:

python setup.py build develop

在这里插入图片描述
成功安装detectron2。

在安装detecteron中,遇到报错:

error: command ‘C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\bin\nvcc.exe’ failed with exit code 1
解决办法:

找到如下文件:

detectron2\layers\csrc\nms_rotated\nms_rotated_cuda.cudetectron2\layers\csrc\nms_rotated\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 setup.py build develop。

编译的时候failed with exit status 1错误

编译的时候,我们遇到了“command ‘…/…/bin/nvcc.exe’ failed with exit status 1”,修改策略
“…/…/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cuda.cu” 文件中#include “…” 路径错误 ,然后编译成功。

运行demo.py

python demo.py --config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input rgb.png --output 1.png --opts MODEL.WEIGHTS model_final_f10217.pkl
http://www.lryc.cn/news/425010.html

相关文章:

  • 函数(子程序)的常见、易混淆概念详解【对初学者有帮助】
  • TiDB-从0到1-DM工具
  • AppScan——Web 应用安全扫描的得力工具
  • 虚幻5|AI行为树,进阶篇
  • 在 Spring Boot 中配置 Tomcat 监听多个端口
  • stm32f407新建项目工程及烧录
  • c++中加不加const的值传递和引用传递的区别
  • Qt的窗口设置
  • 51单片机-LCD1602显示屏
  • 多模态分析代理 MAIA:多智能体解决 视觉模型 黑盒问题
  • AT360-6T杭州中科微单频高精度授时模块场景应用
  • Python酷库之旅-第三方库Pandas(081)
  • C语言基础⑩——构造类型(结构体)
  • 宝兰德荣获openEuler项目群青铜捐赠人称号,共筑开源生态繁荣新篇章
  • 【Python单元测试】学习笔记3
  • OpenSSL源码编译及Debug
  • go之goburrow/modbus 学习
  • 开放词汇目标检测(Open-Vocabulary Object Detection, OVOD)算法是什么?
  • 【教程】Ubuntu给pycharm添加侧边栏快捷方式
  • 三个月外贸小白好迷茫,该何去何从?
  • MySQL数据库——基本查询(Create)
  • spring-security-1-快速入门
  • 5 大场景上手通义灵码企业知识库 RAG
  • 免费远程控制电脑的软件有哪些?
  • Linux软件包yum
  • 网页的切换与嵌套
  • 基于飞桨框架的稀疏计算使用指南
  • 启明云端WT32C3-S6物联网模块,乐鑫ESP32-C3芯片技术应用
  • 超越流水线,企业研发规范落地新思路
  • 财务会计与管理会计(四)