当前位置:网站首页>win10下基于anaconda的detectron2安装
win10下基于anaconda的detectron2安装
2022-07-24 00:19:00 【simple_whu】
win10下基于anaconda的detectron2安装
在Anaconda中创建虚拟环境
例如,我给创建的虚拟环境起名叫mPytorch,执行下面的命令以创建这个环境:
conda create -n mPytorch python=3.7
创建完成后,使用conda activate语句激活该环境。当前激活了哪个环境,运行conda install或者pip install安装的库就存在于哪个环境。激活mPytorch后,运行官方命令安装pytorch和cudatoolkit。
conda activate mPytorch
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
安装cuda的C语言开发包
注意,上一节cudatoolkit安装了哪个版本,就要去英伟达官网下载与其版本对应的C语言cuda开发包,并安装。其下载安装参考该网站。具体下载地址。
下载完成后,双击该安装包,接受默认安装选项,直至安装完成。
安装MSVC编译器
若下载了cuda10.x版本,则应该安装VS2019;若下载了cuda11.x版本,则应该安装VS2022。
安装完成后,应该在开始菜单可以找到x64 Native Tools Command Prompt for VS 2019命令行入口:
下载并编译安装detectron2
虽然官方声称暂不支持windows下编译安装,但是亲测可行。
在GitHub下载detectron2的源码并解压,或者使用git clone命令将仓库复制到本地(如果你安装了Git for windows的话)。
源代码文件夹如图所示:

根据官方教程,要编译和安装detectron2,只需要在命令行执行一句命令:
python -m pip install -e .\detectron2-main\
其中-e后面是源码文件夹路径,可以是绝对路径或相对路径。
但是,windows下想要成功完成编译,需要注意以下几点:
- 安装一系列依赖:
pip3 install easydict
conda install pyyaml
conda install cffi
conda install cython
conda install scipy
pip install pycocotools
- 打开你的
x64 Native Tools Command Prompt for VS 2019或x64 Native Tools Command Prompt for VS 2022,并输入conda activate mPytorch激活conda环境。 - 设置临时环境变量
set DISTUTILS_USE_SDK=1
- 修改源码文件
nms_rotated_cuda.cu:
打开nms_rotated_cuda.cu,将下图中框出部分在行首用’//'注释掉即可。这是为了解决错误信息nms_rotated_cuda.cu(68): error: identifier "single_box_iou_rotated" is undefined,也可以参考此博客。
- 运行python -m pip install -e .\detectron2-main\进行编译和安装。
测试使用detectron2
需要安装opencv。
pip install opencv-python
根据官方示例,下载一个训练好的模型,model_final_280758.pkl,并把它放在detectron2源码的demo文件夹下。
然后在命令行进入demo文件夹,运行命令:
python .\demo.py --config-file ..\configs\COCO-Detection\faster_rcnn_R_50_FPN_3x.yaml --input 你的输入图片名 --opts MODEL.WEIGHTS model_final_280758.pkl

边栏推荐
- Solution to the second game of 2022 Niuke multi school league
- English语法_指示代词 - So
- 合宙ESP32C3基于Arduino IDE框架下配置分区表
- Gbase 8C system table information function (III)
- Pytorch with torch no_ grad(): && model.eval()
- docker搭建sonarqube,mysql5.7环境
- GBase 8c系统表信息函数(一)
- Adaptation scheme of large screen visualization
- Redis 集群hash分片算法(槽位定位算法)
- The name in Qiankun subapplication package.json becomes the default path
猜你喜欢

After openfeign sets circuitbreaker=true, feign's readtimeout expires

加密技术应用

合宙ESP32C3基于Arduino IDE框架下配置分区表

分布式之 CAP 原则

Jenkins uses sonarqube to build pipeline code review project

The universal esp32c3 configures partition tables based on the Arduino ide framework

docker 拉取redis镜像 并运行

Nacos
![[attack and defense world web] difficulty five-star 15 point advanced question: bug](/img/24/4a7f074aac9a08130cf215f0c39b57.png)
[attack and defense world web] difficulty five-star 15 point advanced question: bug

Summarize the plan, clarify the direction, concentrate and start a new situation -- the Counterpart Assistance Project of hexu software has achieved remarkable results
随机推荐
[wechat applet] design and interactive implementation of auction product details page (including countdown and real-time update of bids)
二叉搜索树的简易实现及剖析
Redis持久化机制RDB、AOF
Pytest interface automation test framework | control test case execution
mongodb的多数据源配置
mysql数据库基础
Tencent cloud was affirmed by international professional streaming media evaluation: video coding performance is the best in all three scenarios
Take stock of 10 new layer1 to prepare for the next bull market
Sentinel link mode flow control failure solution
Mysql database foundation
Codeforces Round #807 (Div. 2)(A-D)
GBase 8c 模式可见性查询函数(一)
GBase 8c 访问权限查询函数(三)
Sum of submatrix
Simple implementation and analysis of binary search tree
Gbase 8C session information function (4)
GBase 8c 访问权限访问函数(四)
Scheme for importing XMIND use cases into tapd (with code)
GBase 8c 访问权限查询函数(二)
Redis主从同步机制