出现原因:Python 的输出存在缓冲机制,因此不能实时输出结果至 nohup.out
解决方法:使用 python -u 设置为不使用缓存机制
nohup python -u 你正常使用时的命令 > nohup.out 2>&1 &
举个栗子:
我原本启动训练的命令是:
CUDA_VISIBLE_DEVICES=2 python core/train.py --config configs/celeba-hq_256.yaml --gpus 0
则现在改为:
CUDA_VISIBLE_DEVICES=2 nohup python -u core/train.py --config configs/celeba-hq_256.yaml --gpus 0 > nohup.out 2>&1 &