ubuntu编译安装mmcv 1.6.2和mmsegmentation 0.28.0

环境:

ubuntu16.04,
cuda10.1
python 3.8
pytorch 1.6.0 (cuda10.1 对应的torch版本<=1.8,但是1.8和1.7都试了,mmcv没有编译成功,只有1.6成功了)

1. 编译MMCV

1.1 创建conda环境:

conda create -n openmmlab python==3.8
conda activate openmmlab
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1 -c pytorch

1.2 编译mmcv1.6.2

下载mmcv1.6.2:https://github.com/open-mmlab/mmcv/releases?page=1
参考安装教程:https://mmcv.readthedocs.io/zh_CN/latest/get_started/build.html

cd ../mmcv-1.6.2
pip install -r requirements/optional.txt  #可选
 MMCV_WITH_OPS=1 pip install -e . -v

输出:

Successfully installed addict-2.4.0 mmcv-full-1.6.2 opencv-python-4.6.0.66 packaging-21.3 pyparsing-3.0.9 pyyaml-6.0 yapf-0.32.0

1.3 验证安装

python .dev_scripts/check_installation.py

输出:

TorchVision: 0.7.0
OpenCV: 4.6.0
MMCV: 1.6.2
MMCV Compiler: GCC 5.4
MMCV CUDA Compiler: 10.1

安装成功!

2. 编译MMSegmentation

MMSegmentation和MMCV版本关系,选择mmsegmentation 0.28.0
下载地址:https://github.com/open-mmlab/mmsegmentation/releases
安装教程:https://github.com/open-mmlab/mmsegmentation/blob/master/docs/zh_cn/get_started.md#%E4%BB%8E%E6%BA%90%E7%A0%81%E5%AE%89%E8%A3%85

2.1 编译安装 mmsegmentation 0.28.0

cd ../mmsegmentation
pip install -v -e .

输出:

Successfully installed contourpy-1.0.6 cycler-0.11.0 fonttools-4.38.0 kiwisolver-1.4.4 matplotlib-3.6.2 mmcls-0.24.1 mmsegmentation-0.28.0 prettytable-3.5.0 python-dateutil-2.8.2 wcwidth-0.2.5

2.2 验证安装

python
import mmseg
print(mmseg.__version__)

输出:

0.28.0

安装成功!

2.3 进一步验证推理示例(可选)

下载模型:https://download.openmmlab.com/mmsegmentation/v0.5/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth

python demo/image_demo.py demo/demo.png configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth --device cuda:0 --out-file result.jpg

*注意配置文件和模型的路径是否正确

输出:
ubuntu编译安装mmcv 1.6.2和mmsegmentation 0.28.0_第1张图片

你可能感兴趣的:(BEV,ubuntu,python,linux)