win10 + GTX1660S + CUDA 11.1 + VS 2019 + py3.8+ Pytorch 1.8.1 安装 MMCV + mmdetection + mmsegmentation
当前环境版本:
- Python 3.8.6 (anaconda 虚拟环境)
- PyTorch 1.8.1
- CUDA 11.1
- VS 2019 (需要在path设置环境变量)
- MMCV 1.3.5
- mmdetection 2.13.0
- mmsegmentation 0.13.0
- git (需要用到时,通过anaconda 安装即可)
以管理员身份打开anaconda powershell,否者有一些命令可能无法执行!!
环境搭建:
1.安装VS2019 社区版 (具体步骤跳过,记得安装c++环境)
2.安装anaconda (具体步骤跳过,傻瓜式安装即可,最好别设置系统路径,否则容易与系统python路径冲突)
3.安装cuda
下载cuda, cuda下载地址
conda create -n open-mmlab python=3.8 -y
conda activate open-mmlab
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
安装 mmcv
安装新的mmcv(1.3.5),以下直接摘抄自官方教程:
你需要知道如何设置环境变量,接下来的过程强烈需要此技能
设置python环境
Prepare MMCV source code
git clone https://github.com/open-mmlab/mmcv.git cd mmcv
Install required Python packages
pip3 install -r requirements.txt
构建和安装 MMCV
通用步骤
Set up MSVC compiler
将
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx86\x64
添加到环境变量PATH
, 这样cl.exe
可以在控制台中所有路径中被调用。(base) PS C:\Users\xxx> cl Microsoft (R) C/C++ Optimizing Compiler Version 19.27.29111 for x64 Copyright (C) Microsoft Corporation. All rights reserved.usage: cl [ option... ] filename... [ / link linkoption... ]
为了兼容性, 我们使用 x86架构宿主的 x64目标编译. 注意在路径中选择
Hostx86\x64
.
Option 3: Build MMCV (full version with CUDA)
通过
ls env:
命令,确定CUDA_PATH
orCUDA_HOME
已经在envs
中, 输出应如下:
一般来说cuda安装时,路径已经被添加到系统。 如果没有, 或者有多个不同版本cuda, 需要在控制台中制定
CUDA_HOME
路径如下所示(根据需要使用的版本):$env:CUDA_HOME = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2" # OR $env:CUDA_HOME = $env:CUDA_PATH_V10_2 # if CUDA_PATH_V10_2 is in envs:
设置 CUDA 架构
# Suppose you are using 1660s, which is of capability 7.5 $env:TORCH_CUDA_ARCH_LIST="7.5"
根据此文章查看自己的显卡算力,我查到的是7.5,我的这个数值在官网上查不到。
- 进行安装,步骤如下,依次输入如下指令
$env:MMCV_WITH_OPS = 1$env:MAX_JOBS = 8 # based on available number of CPU cores and amount of memory# buildpython setup.py build_ext # if success, cl will be launched to compile ops# installpython setup.py develop# checkpip list
如果采用
注意: 如果使用 PyTorch 1.6.0, 可能会遇到一些错误this issue. 需要根据 this pull request 修改pytorch的安装源码.
由于我的pytorch是1.8.1的版本,并未遇到此问题。安装完成后在安装列表里可以看到mmcv-full
安装mmdetection
1.准备和安装
这里当前安装的版本为2.13.0,参考教程
由于前面安装mmcv已经将大部分组件安装完成,然后直接安装mmdetection即可:
cd ..
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e . # or "python setup.py develop"
执行以上语句,很容易就安装完成了
2.验证
通过以下代码验证:
from mmdet.apis import init_detector, inference_detector, show_result_pyplotconfig_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
# download the checkpoint from model zoo and put it in `checkpoints/`
# url: http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cuda:0'
# init a detector
model = init_detector(config_file, checkpoint_file, device=device)
# inference the demo image
result = inference_detector(model, 'demo/demo.jpg')
# show the results
show_result_pyplot(model, 'demo/demo.jpg', result)
首先,下载预训练模型到checkpoints。运行结果如下:
注意: 在我在另一台电脑上运行此测试代码的时候出现了这个问题:
该问题是因为多重引用libiomp5md.dll,我通过everything软件查找 libiomp5md.dll的位置,将pytorch中的libiomp5md.dll删除了,然后就可以正常运行了,不知道后面是否还会出现其他问题,因此可以先将该文件备份一下。
安装mmsegmentation
此过程完全参考官方指导:
首先可以看到,我们采用的当前最新版本0.13.0,需要mmcv-full>=1.3.1, 1.4版本当前还没出。
因为在安装mmcv的时候环境都已经铺垫好了,我们可以直接进入mmsegmentation的安装。
1.mmsegmentation安装:
cd ..
git clone https://github.com/open-mmlab/mmsegmentation.git
cd mmsegmentation
pip install -e . # or "python setup.py develop"
2.验证
很快就安装好了,然后我们来测试一下官方指导中Verification的代码是否可以运行:
首先下载预训练模型,放在项目下的checkpoints目录下,然后执行代码:
from mmseg.apis import inference_segmentor, init_segmentorimport mmcvconfig_file = 'configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py'checkpoint_file = 'checkpoints/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth'# build the model from a config file and a checkpoint file
model = init_segmentor(config_file, checkpoint_file, device='cuda:0')# test a single image and show the results
img = 'demo/demo.png' # or img = mmcv.imread(img), which will only load it onceresult = inference_segmentor(model, img)# visualize the results in a new window
model.show_result(img, result, show=True)# or save the visualization results to image files
# you can change the opacity of the painted segmentation map in (0, 1].
model.show_result(img, result, out_file='result.jpg', opacity=0.5)
win10 + GTX1660S + CUDA 11.1 + VS 2019 + py3.8+ Pytorch 1.8.1 安装 MMCV + mmdetection + mmsegmentation相关推荐
- 来自GPU的Hello World-基于Win10+VS2019+CUDA 11.0搭建CUDA编程环境
序 CPU和GPU 当代计算机的两个核心,GPU计算与CPU计算的结合,使得原本的计算性能得到大幅度的提高,两者功能的互补性使得CPU+GPU的异构并行计算得到快速发展.为了支持使用CPU+GPU ...
- Win10,Cuda 11.1 下载与安装
1.地址:https://developer.nvidia.com/cuda-toolkit-archive,选择版本 选择配置,下载安装包 2.点击cuda_11.1.1_456.81_win10. ...
- 【PyTorch】切记:GeForce RTX 3090 显卡仅支持 CUDA 11 以上的版本!
问题描述 前不久给新来的 2台 8 张 GeForce RTX 3090 服务器配置了深度学习环境(配置教程参考这篇文章),最近在使用的时候却遇到了各种问题. 问题 1:GeForce RTX 309 ...
- 最新CUDA环境配置(Win10 + CUDA 11.6 + VS2019)
最新CUDA环境配置(Win10 + CUDA 11.6 + VS2019) 本篇博客根据NVIDIA 官方文档所述, 并根据自己实践得出. 供各位需要的朋友参考. 1.前言 本篇文章的软件环境为: ...
- python opencv调用cuda_Win10使用VS2019从源码编译OpenCV 4.4 + CUDA 11.0 + Cudnn 8.0 + python3
本文主要介绍Win10使用VS2019从源码编译OpenCV 4.4,并使用opencv_contrib支持CUDA 11.0 + Cudnn 8.0,以及对python3的支持. 1 首先准备安装环 ...
- 购买阿里云GPU虚拟化型实例规格族vgn6i抢占式实例并搭建CUDA 11.5和cuDNN 8.3.0
1.阿里云GPU虚拟化型实例规格族vgn6i 官网地址:https://help.aliyun.com/document_detail/25378.htm?spm=a2c4g.11186623.0.0 ...
- CUDA 11.3安装
显卡驱动 1. 检查cuda对应driver版本: https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#title-n ...
- win10 下cuda 9.0 卸载
win10 下cuda 9.0 卸载 1.首先 对于cuda8.0.cuda7.5的卸载都可以兼容 安装cuda9.0之后,电脑原来的NVIDIA图形驱动会被更新,NVIDIA Physx系统软件也会 ...
- CUDA 11功能清单
CUDA 11功能清单 基于NVIDIA Ampere GPU架构的新型NVIDIA A100 GPU在加速计算方面实现了最大的飞跃.A100 GPU具有革命性的硬件功能,CUDA 11与A100一起 ...
最新文章
- UI设计师面试如何操作才能获得高薪
- 【2017上半年中国AI融资英雄榜】TOP10融资50亿元,二八定律明显
- vc++获取的蓝牙设备信息中rssi的值_Android低功耗蓝牙总结
- Sublime text无法自动通过package control安装插件的研究
- flutter offset_Flutter 仿微信界面聊天室 | 基于 (Flutter+Dart) 聊天实例
- [c#]获取exchange中的图片
- 论卢伟冰加入小米公司后的变化
- 树的点分治(HDU 5977 2016ICPC大连 G: Garden of Eden)
- 28. JavaScript 库
- 循环赛日常表算法(N可为奇数和偶数)
- MDM9607编译出现ERROR: Only one copy of bitbake should be run against a build directory
- CycloneII之EDA及学术开发功能描述
- MySql NTERVAL函数
- 图神经网络笔记(二)——卷积图神经网络概述
- 计算机起源于发展论文,关于计算机起源及发展的论文
- swagger2搭配knife4j 隐藏实体类的属性/字段
- 第五章:MySQL主从复制
- IDEA解决打开properties乱码问题
- 51单片机 玩转按键加减切换+数码管+Proteus仿真
- SpringMVC之HandlerMethodReturnValueHandler