防止MMdetection训练进程意外中断的终极方法-nohup
正常的MMdetection训练命令如下:
python tools/train.py <模型配置文件路径>
python tools/train.py work_dirs/deformable-detr_r50_16xb2-50e_coco/deformable-detr_r50_16xb2-50e_coco.py
我们之前讲了继续上次训练的resume参数:
MMdetection恢复训练命令-CSDN博客https://blog.csdn.net/qq_54708219/article/details/148247063?spm=1001.2014.3001.5502这次我们介绍另一种nohup方法,做到训练进程忽略终端信号中断:
nohup语法:
nohup <你要执行的命令> > output.log 2>&1 &
解释如下:
- nohup: 让命令在后台运行,即使终端关闭也不停止。
- > output.log: 将标准输出重定向到output.log文件。
- 2>&1: 将标准错误输出也重定向到标准输出(即同一个日志文件)。
- &: 在后台运行。
例如上面的示例:
nohup python tools/train.py work_dirs/deformable-detr_r50_16xb2-50e_coco/deformable-detr_r50_16xb2-50e_coco.py > train.log 2>&1 &
看到终端显示进程已推到后台,train.log开始记录数据即说明成功: