ubuntu安装mmcv-full看这一篇就够了

背景
跑一个目标检测模型的baseline,baseline地址为https://github.com/yuantn/MI-AOD
安装mmcv-full时出错
设备版本

baseline要求的版本: GPU Linux 开发平台 (推荐使用 Ubuntu 和 CentOS,我们在 Ubuntu 16.04、Ubuntu 18.04、CentOS 7.6 上测试过。) Anaconda3 Python 3.6+ (推荐使用 Python 3.7,我们用它测试过。) PyTorch 1.3+ (推荐使用 PyTorch 1.6,我们用它测试过。) CUDA 9.2+ (推荐使用 CUDA 10.2,我们用它测试过。如果你从源代码来搭建 PyTorch,那么 CUDA 9.0 也可以兼容。) CuDNN (可选项,我们用 CuDNN 7.6.5 测试过。) GCC 5+ (推荐使用 GCC 4.8.5, 5.5.0 and 7.5.0,我们用它们测试过。) MMCV (非常推荐使用 MMCV 1.0.5,我们用它测试过。它是唯一一个和 MMDetection 2.3.0 兼容的 MMCV 版本,这套 MI-AOD 代码是在该版本的 MMDetection 基础上编写的。

我这里版本比baseline要求的要高 ubuntu16.04, cuda 11.4(实验室备的) pytorch(1.10.0) torchvision(0.11.1) python3.7 GCC 5.5.0

正确安装步骤
【ubuntu安装mmcv-full看这一篇就够了】补充我安装pytorch和pytorchvision,cudatoolkit,mmcv-full顺序
由于实验室cuda版本已确定,所以我的版本确定顺序如下:
cuda(11.4)-->cudatoolkit(11.3)-->pytorch(1.10.0),pytorchvision(0.11.1)-->mmcv-full(1.4.2)
  1. 创建python3.7的虚拟环境miaod并激活
conda create -n miaod python=3.7 -y conda activate miaod

  1. 安装pytorch ,torchvision和cudatoolkit
    不确定版本的话看这个https://pytorch.org/
conda install pytorch cudatoolkit=11.3 torchvision -c pytorch

查看安装成功
ubuntu安装mmcv-full看这一篇就够了
文章图片

但是因为conda下载太慢,经常会断,而且我这里遇到了点问题,不知道是不是镜像源配置问题(解决:当时把整个虚拟环境删掉,重新建了),所以可以采用wget方式安装,这里不赘述.
  1. 安装mmcv-full
    这里我执行了
pip install mmcv-full==1.4.2 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.10.0/index.html

官方给出的命令如下:
pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/{cuda_version}/{torch_version}/index.html

其中,{ }中的版本需要替换成对应版本,不知道的可以查看https://github.com/open-mmlab...
ubuntu安装mmcv-full看这一篇就够了
文章图片

点击标记的地方,打开里面的网址,可以查看更多的mmcv版本
ubuntu安装mmcv-full看这一篇就够了
文章图片

  1. 查看是否安装成功
    pip list
    ubuntu安装mmcv-full看这一篇就够了
    文章图片
我的神奇出错步骤
因为要cuda和torch版本要对应,所以参考链接
但是我的cuda是11.4,所以自作聪明把cu114改成了cu114,造孽呀,试了好多次才发现错在一个版本数字上。
个人输入:
pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cu114/torch1.10.0/index.html

贴上部分错误提示
(miaod)gjs@xaserver:~$ pip install mmcv-full Collecting mmcv-full Using cached mmcv-full-1.4.6.tar.gz (438 kB) Requirement already satisfied: addict in ./anaconda3/envs/iaod/lib/python3.7/site-packages (from mmcv-full)(2.4.0) Requirement already satisfied: numpy in ./anaconda3/envs/miaod/lib/python3.7/site-packages (from mmcv-full)(1.21.5) Requirement already satisfied: packaging in ./anaconda3/envs/miaod/lib/python3.7/site-packages (from mmcv-full) (21.3) Requirement already satisfied: Pillow in ./anaconda3/envs/miaod/lib/python3.7/site-packages (from mmcv-full)(9.0.1) Requirement already satisfied: pyyaml in ./anaconda3/envs/miaod/lib/python3.7/site-packages (from mmcv-full)(6.0) Requirement already satisfied: yapf in ./anaconda3/envs/miaod/lib/python3.7/site-packages (from mmcv-full) (0.32.0) Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in ./anaconda3/envs/miaod/lib/python3.7/site-packages (from packaging->mmcv-full) (3.0.7) Building wheels for collected packages: mmcv-full Building wheel for mmcv-full (setup.py) ... error ERROR: Command errored out with exit status 1: command: /home/gjs/anaconda3/envs/miaod/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-j0pjsxbk/mmcv-full_d5394041d9d84b8a8b9d8c96a1f87280/setup.py'"'"'; __file__='"'"'/tmp/pip-install-j0pjsxbk/mmcv-full_d5394041d9d84b8a8b9d8c96a1f87280/setup.py'"'"'; f=getattr(tokenize, '"'"'open'"'"', open)(__file__); code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"'); f.close(); exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-mxbrufls cwd: /tmp/pip-install-j0pjsxbk/mmcv-full_d5394041d9d84b8a8b9d8c96a1f87280/ Complete output (663 lines): running bdist_wheel /home/gjs/anaconda3/envs/miaod/lib/python3.7/site-packages/torch/utils/cpp_extension.py:381: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend. warnings.warn(msg.format('we could not find ninja.')) running build running build_py

ubuntu安装mmcv-full看这一篇就够了
文章图片

致谢
感谢崔大佬,让我对服务器的认识从0.5到1,之后会慢慢增到到10,甚至100的

    推荐阅读