ubuntu16.04安装mmdetection库
一,前言
1.1,更新 pip 和 conda下载源
在下载安装好 python3+pip 或 anconda3 的基础上,建议更新为清华/阿里镜像源(默认的 pip 和 conda下载源速度很慢)。
1,pip 更新下载源为清华源的命令如下:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
2,conda 更新源的方法:
各系统都可以通过修改用户目录下的 .condarc 文件。Windows 用户无法直接创建名为 .condarc 的文件,可先执行 conda config --set show_channel_urls yes 生成该文件之后再修改.condarc 文件内容如下:
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
1.2,查看 conda 和 pip 版本
root# conda --version
conda 22.9.0
root# pip --version
pip 20.2.4 from /opt/miniconda3/lib/python3.8/site-packages/pip (python 3.8)
二,MMDetection 简介
MMDetection 是一个基于 PyTorch 的目标检测开源工具箱。它是 OpenMMLab 项目的一部分。主分支代码目前支持 PyTorch 1.5 以上的版本。主要特性为:
- 模块化设计
- 丰富的即插即用的算法和模型
- 速度快
- 性能高
更多详情请参考 MMDetection 仓库 README。
三,MMDetection 安装
3.1,依赖环境
- 系统:首选 Linux,其次
macOS和Windows(理论上支持,实际安装需要踩很多坑) Python 3.6+- 首选 CUDA 11.3+、其次推荐 CUDA 9.2+
- 首选 Pytorch 1.9+,其次推荐 PyTorch 1.3+
GCC 5+- MMCV
3.2,安装过程记录
1,安装操作系统+cuda
我是在 docker 容器中安装和进行深度学习算法开发的,其操作系统、cuda、gcc 环境如下:

2,安装 Anconda3
官网下载 Anconda3 linux 安装脚本,并安装 Anconda3(很好装一路 yes 即可),并使用 conda 新建虚拟环境,并激活虚拟环境进入。
conda create -n mmlab python=3.8 -y # 创建 mmlab 的虚拟环境,其中python解释器版本为3.8(python3.9版本不行, 没有pytorch_cuda11.0版本)
conda activate mmlab # 激活虚拟环境进入
虚拟环境安装成功后的部分过程截图如下所示:

如果你激活虚拟环境出现如下所示错误。
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
可通过以下命令重新激活 conda 环境,即可解决问题,方法参考自 stack overflow 问题。
source ~/anaconda3/etc/profile.d/conda.sh # anaconda3 的安装路径有可能不一样,自行修改
conda activate mmlab
3,安装 pytorch-gpu
首选安装 pytorch-gpu 版本,如果是在线安装命令如下。
conda install pytorch=1.7.1 cudatoolkit=11.0 torchvision=0.8.2 -c pytorch
官网命令的 cuda11.0 的 torchaudio==0.7.2 版本不存在,故去除。
安装过程信息(记得检查 pytorch 版本是 cuda11.0 的)截图如下:

安装成功后,进入 python 解释器环境,运行以下命令,判断 pytorch-gpu 版本是否安装成功。
>>> import torch
>>> torch.cuda.is_available()
True
>>> torch.cuda.device_count()
2
>>>
同时可通过以下命令查看 CUDA 和 PyTorch 的版本
python -c 'import torch;print(torch.__version__);print(torch.version.cuda)'
总的来说,pytorch 等各种 python 包有离线和在线两种方式安装:
- 在线:
conda/pip方法安装,详细命令参考 pytorch 官网,但是这种方式实际测试下来可能会有问题,需要自己肉眼检查安装的版本是否匹配。 - 离线:浏览器下载安装包,然后通过
pip或者conda方式离线安装。
不通过浏览器下载
whl包,而是pip install https://download.pytorch.org/whl/cu110/torch-1.7.1%2Bcu110-cp39-cp39-linux_x86_64.whl方式可能会有很多问题,比如网络问题可能会导致安装失败。
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f74f60d6760>: Failed to establish a new connection: Errno 101 Network is unreachable')': /whl/cu110/torch-1.7.1%2Bcu110-cp39-cp39-linux_x86_64.whl
或者下载到一半的网络连接时常超过限制。
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='download.pytorch.org', port=443): Read timed out.
4,安装 mmdetection
不建议安装 cpu 版本,因为很多算子不可用,其次截止到2022-11-3日,macos 系统 cpu 环境的
mmdet.apis是不可用的。
建议使用 MIM 来自动安装 MMDetection 及其相关依赖包-mmcv-full 。
pip install openmim # 或者 pip install -U openmim
mim install mmdet

参考资料
mmdetection和pytorch官网- https://download.pytorch.org/whl/torch_stable.html
ubuntu16.04安装mmdetection库的更多相关文章
- ubuntu16.04安装libzip库
sudo apt install libzip-dev
- Ubuntu16.04安装pcl库
sudo apt-get install libpcl-dev sudo apt-get install pcl-tools
- ubuntu16.04安装python3,numpy,pandas等量化计算库
ubunt安装python3 sudo add-apt-repository ppa:fkrull/deadsnakessudo apt-get updatesudo apt-get install ...
- Ubuntu16.04安装opencv for python/c++
Ubuntu16.04安装opencv for python/c++ 网上关于opencv的安装已经有了不少资料,但是没有一篇资料能让我一次性安装成功,因此花费了大量时间去解决各种意外,希望这篇能给一 ...
- ubuntu16.04安装不上有道词典的解决办法
转自:http://www.linuxdiyf.com/linux/21143.html ubuntu16.04安装不上有道词典,提示: le@hu-pc:~/下载$ sudo dpkg -i you ...
- Ubuntu16.04安装cuda9.0+cudnn7.0
Ubuntu16.04安装cuda9.0+cudnn7.0 这篇记录拖了好久,估计是去年6月份就已经安装过几遍,然后一方面因为俺比较懒,一方面后面没有经常在自己电脑上跑算法,比较少装cuda和cudn ...
- 阿里云学生服务器搭建网站-Ubuntu16.04安装php开发环境
阿里云学生服务器搭建网站(2)-Ubuntu16.04安装php开发环境 优秀博文:https://www.linuxidc.com/Linux/2016-10/136327.htm https:/ ...
- ubuntu16.04安装nvidia ,cuda(待完善)
ubuntu16.04安装nvidia 1.首先查看自己的pc显卡的型号 ubuntu16.04 查看方法: 查看GPU型号 :lspci | grep -i nvidia 查看NVIDIA驱动版本: ...
- Ubuntu16.04安装tensorflow+安装opencv+安装openslide+安装搜狗输入法
Ubuntu16.04在cuda以及cudnn安装好之后,安装tensorflow,tensorflow以及opencv可以到网上下载对应的安装包并且直接在安装包所在的路径下直接通过pip与conda ...
- Ubuntu16.04 安装和卸载MySQL数据库
Ubuntu16.04 安装和卸载MySQL数据库 1 安装 安装非常简单,只需要三个命令 1.1 安装服务端 sudo apt-get install mysql-server 在这一步过程中会有提 ...
随机推荐
- 微信支付java版(含视频讲解)
1.背景 实际开发中用到微信支付的概率非常大, 至于为什么这里不必要我多少...... 微信支付大体需要对接的核心接口有 其实大部分支付都是这些,就像上一节我们讲的支付宝支付一样 这里以常用的H5支付 ...
- Kruskal和Prim模板
例题:P3366 [模板]最小生成树 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) Kruskal #include <bits/stdc++.h> #define d ...
- SMU Spring 2023 Contest Round 2(待补
M. Different Billing #include <map> #include <set> #include <cmath> #include <q ...
- CF650D Zip-line
CF650D Zip-line 大概题面: 给定一个长度为 \(n\) 的序列以及\(m\)个操作,每个操作形如" \(a_i,b_i\) ",表示将序列中第 \(a_i\) 个数 ...
- Homebrew 卸载 Wireshark 报错
我在使用 Homebrew 安装 Wireshark 的时候,Homebrew 要求我输入密码.此时我又不想安转 Wireshark 了,于是我没有输入密码并且按下了 Ctrl + C.后来,我又尝试 ...
- 折腾 Quickwit,Rust 编写的分布式搜索引擎 - 可观测性之分布式追踪
概述 分布式追踪是一种跟踪应用程序请求流经不同服务(如前端.后端.数据库等)的过程.它是一个强大的工具,可以帮助您了解应用程序的工作原理并调试性能问题. Quickwit 是一个用于索引和搜索非结构化 ...
- 如何保证 Redis 的高并发和高可用?讨论redis的单点,高可用,集群
如何保证 Redis 的高并发和高可用?讨论redis的单点,高可用,集群. 打开GitHub搜索redis,边可以看到,该项目的介绍是这样的: Redis is an in-memory datab ...
- 录音转文字SDK哪家强?
最近在做一款录音App,有一个模块是录音转文字功能,于是对比了市面上常见的API,国内做的比较大的主要有讯飞.腾讯.阿里.百度.华为. 讯飞 讯飞在国内做语音SDK是做的比较早的,翻译出来的准确率挺不 ...
- Hadoop & Redis未授权漏洞实战——Vulfocus服务攻防
什么是未授权访问漏洞?Hadoop & Redis靶场实战--Vulfocus服务攻防 一.介绍 未授权访问,也称为未经授权的访问或非法访问,是指在没有得到适当权限或授权的情况下,个人或系统访 ...
- Windows右下角时间显示具体星期
事件起因: 有时候脑子不清楚,过着过着就会忘记今天是星期几,错过一些重要事情,于是乎就想看看Windows右下角能不能显示到具体星期,果然在查了资料之后这个需求可以达成 解决办法: 控制面板 - 日期 ...