我是靠谱客的博主 悲凉柠檬,这篇文章主要介绍mmsegmentation V0.27.0环境搭建(一),现在分享给大家,希望可以做个参考。

1、官网

在这里插入图片描述

2、兼容的MMSegmentation和MMCV版本如下。请安装正确版本的MMCV,以避免安装问题。

在这里插入图片描述

3、Installation(Linux系统环境安装)

1、创建虚拟环境并安装pytorch(Step 1. Create a conda environment and activate it)

1、pytorch 与cudn的匹配版本

pytorch 与cudn的匹配版本

2、创建虚拟环境并安装pytorch

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
conda create -n openmmseg python=3.7 -y #创建环境 conda activate mmdetection #激活环境 conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch #安装 PyTorch and torchvision (官方) #如果网不好,可以这样安装 pip3 install torch==1.8.2+cu102 torchvision==0.9.2+cu102 torchaudio===0.8.2 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com pip install torch==1.11.0+cu115 torchvision==0.12.0+cu115 torchaudio==0.11.0 -f https://download.pytorch.org/whl/torch_stable.html -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com #验证是否安装成功 >>> import torchvision >>> import torch >>> import.__version__ File "<stdin>", line 1 import.__version__ ^ SyntaxError: invalid syntax >>> torch.__version__ '1.8.2+cu102'

3、安装mmcv-full

下面是cuda、pytorch和mmcv-full的版本
在这里插入图片描述
可查看cu102-torch1.8.0支持的mmcv版本号
可查看cu102-torch1.6.0支持的mmcv版本号
查看torch1.6.0支持的mmcv-full的版本
注意:上面提供的预构建包不包括所有版本的mmcv-full,您可以单击相应的链接(查看torch1.6.0支持的mmcv-full的版本)来查看支持的版本。例如,您可以单击cu102-torch1.8.0,可以看到cu102-torch1.8.0只提供1.3.0及以上版本的mmcv-full。此外,从v1.3.17开始,我们不再提供使用PyTorch 1.3和1.4编译的完整的mmcv预构建包。你可以在这里找到用PyTorch 1.3和1.4编译的以前版本。在我们的Cl中,兼容性仍然得到保证,但我们将在明年放弃对PyTorch 1.3和1.4的支持
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
注意:上面提供的预构建包不包括所有版本的mmcv-full,您可以单击相应的链接来查看支持的版本。例如,您可以单击cu102-torch1.8.0,可以看到cu102-torch1.8.0只提供1.3.0及以上版本的mmcv-full。此外,从v1.3.17开始,我们不再提供使用PyTorch 1.3 & 1.4编译的完整mmcv预构建包。您可以在这里找到使用PyTorch 1.3和1.4编译的以前版本。在我们的Cl中仍然确保了兼容性,但我们将在明年放弃对PyTorch 1.3和1.4的支持。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#Install mmcv-full. 安装mmcv-full pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html Please replace {cu_version} and {torch_version} in the url to your desired one. For example, to install the latest mmcv-full with CUDA 11.0 and PyTorch 1.7.0, use the following command: #案例1:(安装最新版本) pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.8.0/index.html #案例2:(安装特定版本) pip install mmcv-full==1.3.13 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html #明确mmcv-full的版本号 pip install mmcv-full==1.4.4 -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.8.0/index.html -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com #(镜像加速安装最新版本) pip install mmcv-full==1.6.0 -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.8.0/index.html -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com #验证是否安装成功 import mmcv #如果出现 >>> import mmcv No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda-10.2' #我们去看看驱动: nvidia-smi 如果返回NVIDIA驱动失效简单解决方案:NVIDIA-SMI has failed because it couldn‘t communicate with the NVIDIA driver. 这种情况是由于重启服务器,linux内核升级导致的,由于linux内核升级,之前的Nvidia驱动就不匹配连接了,但是此时Nvidia驱动还在,可以通过命令 nvcc -V 找到答案。 #解决方法: 查看已安装驱动的版本信息 ls /usr/src | grep nvidia (mmdetection) lhy@thales-Super-Server:~$ ls /usr/src | grep nvidia nvidia-440.33.01 #进行下列操作 sudo apt-get install dkms sudo dkms install -m nvidia -v 440.33.01 #然后进行验证: (mmdetection) lhy@thales-Super-Server:~$ nvidia-smi Fri May 6 00:56:02 2022 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 440.33.01 Driver Version: 440.33.01 CUDA Version: 10.2 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 TITAN RTX Off | 00000000:02:00.0 Off | N/A | | 0% 47C P0 54W / 280W | 0MiB / 24220MiB | 0% Default | +-------------------------------+----------------------+----------------------+ | 1 TITAN RTX Off | 00000000:03:00.0 Off | N/A | | 0% 47C P0 65W / 280W | 0MiB / 24220MiB | 0% Default | +-------------------------------+----------------------+----------------------+ | 2 TITAN RTX Off | 00000000:82:00.0 Off | N/A | | 0% 48C P0 63W / 280W | 0MiB / 24220MiB | 1% Default | +-------------------------------+----------------------+----------------------+ | 3 TITAN RTX Off | 00000000:83:00.0 Off | N/A | | 0% 46C P0 42W / 280W | 0MiB / 24220MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | No running processes found | +-----------------------------------------------------------------------------+ (mmdetection) lhy@thales-Super-Server:~$ python Python 3.7.13 (default, Mar 29 2022, 02:18:16) [GCC 7.5.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. >>> import mmcv >>> mmcv.__version__ '1.4.4'

4、MMSegmention安装

在这里插入图片描述

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
git clone https://github.com/open-mmlab/mmsegmentation.git cd mmsegmentation 安装构建要求,然后安装mmdetection。(我们通过github repo安装pycocotools而不是pypi,因为pypi版本较旧并且与最新的numpy不兼容。) pip install cython -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com pip install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI" 如果网不好,可以按照下面的步骤安装 git clone https://github.com/cocodataset/cocoapi.git cd cocoapi/PythonAPI python setup.py build_ext --inplace python setup.py build_ext install pip install -e . # or "python setup.py develop" Using /home/lhy/anaconda3/envs/mmsegmention/lib/python3.7/site-packages Finished processing dependencies for mmsegmentation==0.24.1

在这里插入图片描述

4、 测试环境搭建成功

复制代码
1
2
python demo/image_demo.py demo/demo.png configs/swin/upernet_swin_tiny_patch4_window7_512x512_160k_ade20k.py upernet_swin_tiny_patch4_window7_512x512.pth --palette ade

在这里插入图片描述

5、安装其他库

linux chown命令解除文件夹的root权限限制

复制代码
1
2
sudo chown -R demouser file

这个命令可以解除linux文件的超级权限限制

1、安装gdal

添加源

复制代码
1
2
sudo add-apt-repository ppa:ubuntugis && sudo apt update
复制代码
1
2
conda install gdal

验证库安装成功

复制代码
1
2
3
4
5
>>> from osgeo import gdal >>> from osgeo import ogr >>> from osgeo import osr

2、安装scikit-image

复制代码
1
2
pip install scikit-image -i https://pypi.tuna.tsinghua.edu.cn/simple

3、安装fiona和rasterio

复制代码
1
2
3
pip install fiona -i https://pypi.tuna.tsinghua.edu.cn/simple pip install rasterio -i https://pypi.tuna.tsinghua.edu.cn/simple

4、安装albumentations

复制代码
1
2
pip install albumentations -i https://pypi.tuna.tsinghua.edu.cn/simple

最后

以上就是悲凉柠檬最近收集整理的关于mmsegmentation V0.27.0环境搭建(一)的全部内容,更多相关mmsegmentation内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(48)

评论列表共有 0 条评论

立即
投稿
返回
顶部