win 11,cuda 11.1,torch 1.9.0,VS 2019,Anaconda环境下安装detectron2

基于https://www.bilibili.com/video/BV1jZ4y1W7Nb?spm_id_from=333.999.0.0视频在win11下成功实现了detectron2的安装,记得下载up主的教程素材。

具体步骤

1、先创建虚拟环境

conda create -n detectron2 python=3.8

这里需要python 3.8版本(注意up主的是3.7),否则cudatoolkit 11.1好像无法安装。

2、激活虚拟环境

conda activate detectron2

3、安装torch 1.9.0以及相对于的torchvision 0.10.0

安装路径:https://download.pytorch.org/whl/torch_stable.html,下载对应的版本,使用“pip install +文件名”命令安装。

4、安装cudatoolkit 11.1

conda install cudatoolkit=11.1 -c pytorch
conda install cudatoolkit=11.1

尝试两种安装命令,显示安装成功即可。

5、安装一些库

pip install cython opencv-python pillow  matplotlib termcolor cloudpickle tabulate tensorboard termcolor tqdm yacs mock fvcore pydot wheel future

6、安装pycocotools

7、安装up主提供的步骤修改一些文件,只用修改cpp_extension.py文件即可

8、安装detectron2

python setup.py build develop
python setup.py build --force develop

尝试两种安装命令,显示安装成功即可。

遇到的一些报错及解决方法

1、from detectron2 import _C
ImportError: DLL load failed: 找不到指定的程序。

这个是detectron2未成功安装,重新进行第8步。

2、error: Microsoft Visual C++ 14.0 or greater is required. Get it with Microsoft C++ Build Tools: https://visualstudio.microsoft.com/visual-cpp-build-tools/

可以参考一下https://blog.csdn.net/weixin_42644340/article/details/109178660,重新打开anaconda powershell,输出cmd,并输入cl,随后进行一下操作:

SET MSSdk=1
SET DISTUTILS_USE_SDK=1
call “C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat” amd64 -vcvars_ver=14.29

注意最后一步中的版本号可能不一样。

3、成功安装detectron2后运行程序报错RuntimeError: Not compiled with GPU support

参照https://www.bilibili.com/video/BV1m4411m7uZ?spm_id_from=333.999.0.0,安装cuda11.1和cudnn。

https://pan.baidu.com/s/1yC3nBCMINhuHBZ8NsnD-iA

提取码:juis

安装完成后重新进行第8步detectron2的安装。

参考文献

https://blog.csdn.net/weixin_42644340/article/details/109178660

https://blog.csdn.net/Ema1997/article/details/107339560

上一篇:C# 日期格式化以及日期常用方法


下一篇:C语言排序算法