Files
insightface/recognition/partial_fc/mxnet/README_CN.md

125 lines
3.3 KiB
Markdown
Raw Normal View History

2020-11-06 20:26:18 +08:00
## 目录
## Contents
[Partial FC](https://arxiv.org/abs/2010.05222)
- [如何安装](#如何安装)
- [如何运行](#如何运行)
- [错误排查](#错误排查)
2020-11-02 22:18:40 +08:00
## 如何安装
2020-11-02 23:23:12 +08:00
2020-11-06 20:24:35 +08:00
### 1. python依赖
2020-11-02 23:29:18 +08:00
使用以下命令
```shell script
2020-11-02 23:23:12 +08:00
pip install easydict mxboard opencv-python tqdm
2020-11-02 23:29:18 +08:00
```
2020-11-02 23:23:12 +08:00
2020-11-06 20:27:16 +08:00
### 2. 安装nccl
2020-11-02 23:23:12 +08:00
nccl可以不用装但是装上速度更快nccl安装需要对应cuda版本安装方法参考下边链接:
2020-11-02 23:33:10 +08:00
[**NCCL**](https://docs.nvidia.com/deeplearning/nccl/install-guide/index.html)
2020-11-02 23:23:12 +08:00
2020-11-06 20:27:16 +08:00
### 3. 安装openmpi
2020-11-02 23:23:12 +08:00
openmpi必须安装必须采纳我的脚本编译源码安装
2020-11-06 20:00:18 +08:00
[**OpenMPI**](setup-utils/install-mpi.sh)
2020-11-02 23:23:12 +08:00
2020-11-06 20:27:16 +08:00
### 4. 安装horovod, mxnet
2020-11-02 23:29:18 +08:00
有些版本的mxnet的horovod无法安装参考下方表格强烈建议使用**mxnet==1.6.0**和**cuda==10.1**
2020-11-02 23:14:34 +08:00
| mxnet |horovod | cuda |
| :---: | :--- | :---: |
2020-11-02 23:23:12 +08:00
| 1.4.0 | x | x |
2020-11-02 23:14:34 +08:00
| 1.5.0 | 可以安装 | cuda10.0 |
2020-11-02 23:23:12 +08:00
| 1.5.1 | x | x |
2020-11-10 13:31:45 +08:00
| 1.6.0.post0 | 可以安装 | cuda10.1 |
2020-11-02 23:23:12 +08:00
| 1.7.0 | x | x |
2020-11-02 23:14:34 +08:00
2020-11-02 23:33:10 +08:00
horovod 安装方法如下:
2020-11-06 20:00:18 +08:00
[**Horovod**](setup-utils/install-horovod.sh)
2020-11-02 22:10:56 +08:00
2020-11-02 23:31:27 +08:00
horovod 安装完成后使用下面的命令检查horovod是否安装成功(nccl有没有都可以有nccl会更快)
```shell script
# Horovod v0.19.2:
# Available Frameworks:
# [ ] TensorFlow
# [ ] PyTorch
# [X] MXNet
#
# Available Controllers:
# [X] MPI
# [X] Gloo
#
# Available Tensor Operations:
# [X] NCCL
# [ ] DDL
# [ ] CCL
# [X] MPI
# [X] Gloo
```
2020-11-06 20:24:35 +08:00
### 5. ssh无密登录
2020-11-02 22:24:11 +08:00
使用多机分布式训练的时候,每台机器都需要设置无密登录,包括自己与自己,无密码登录具体可见:
这里推荐一个简单的命令:
```shell script
ssh-copy-id user@ip
```
2020-11-02 22:18:40 +08:00
## 如何运行
`horovod`底层调用的还是`mpi`mpi的概念是你有多少块GPU就要启动多少个进程有两种方法启动训练使用`horovodrun`或者`mpirun`
2020-11-06 20:23:52 +08:00
### 1. 使用 horovodrun 运行
2020-11-02 22:10:56 +08:00
2020-11-02 22:21:00 +08:00
运行8卡(单机)
2020-11-02 22:10:56 +08:00
```shell script
horovodrun -np 8 -H localhost:8 bash config.sh
```
2020-11-02 22:21:00 +08:00
运行16卡(两台机器)
2020-11-02 22:10:56 +08:00
```shell script
horovodrun -np 16 -H ip1:8,ip2:8 bash config.sh
```
2020-11-06 20:24:35 +08:00
### 2. 使用 mpirun 运行
2020-11-02 22:21:00 +08:00
2020-11-02 22:10:56 +08:00
```shell script
bash run.sh
```
2020-11-06 19:49:40 +08:00
## 错误排查
2020-11-02 22:18:40 +08:00
2020-11-06 19:49:40 +08:00
QQ群711302608
2020-11-02 22:18:40 +08:00
2020-11-06 19:49:40 +08:00
### 检查Horovod是否安装成功
2020-11-02 22:18:40 +08:00
2020-11-06 19:49:40 +08:00
运行这个命令 `horovodrun --check` 来检查horovod是否安装成功。
2020-11-02 22:10:56 +08:00
2020-11-06 19:49:40 +08:00
### 检查你的CUDA版本是否与mxnet匹配比如mxnet-cu101需要的cuda版本为CUDA10.1
2020-11-02 23:31:27 +08:00
2020-11-02 22:10:56 +08:00
```shell script
# Make sure your cuda version is same as mxnet, such as mxnet-cu101 (CUDA 10.1)
/usr/local/cuda/bin/nvcc -V
# nvcc: NVIDIA (R) Cuda compiler driver
# Copyright (c) 2005-2019 NVIDIA Corporation
# Built on Wed_Apr_24_19:10:27_PDT_2019
# Cuda compilation tools, release 10.1, V10.1.168
```
2020-11-06 19:49:40 +08:00
### 屏蔽IO对训练速度的影响
可以在`config.py`中开启debug模式来屏蔽IO看看是否是IO对性能的影响。
### 将数据挂载到内存盘来提高训练速度。
如果你发现你训练速度的瓶颈是IO的话你可以把数据挂载到内存盘来提高训练的速度挂载的命令如下
需要注意的是你的RAM必须足够的大。
2020-11-02 22:10:56 +08:00
```shell script
# If your RAM has 256G
sudo mkdir /train_tmp
mount -t tmpfs -o size=140G tmpfs /train_tmp
```