PyTorch: Logging during model.fit()
I'm using pytorch/fastai for training models. Since I'm working with remote machines, I am running the scripts using nohup python $1 &gt;$2 2&gt;&amp;1 &amp; with redirection to logging file like &quot;log123.txt&quot;.
My problem is that during the model.fit() phase with scheduler, I can't see the progress in the file after each epoch like in console and the results are written to my logging file after the model.fit() finishes training. It works fine when I watch the process in console.
Is there any workaround for this?

This may be due to file buffering. You can disable it for python process like this:

Run your script with -u options. Example:

python -u my_script.py &gt; log.txt

Use PYTHONUNBUFFERED:

PYTHONUNBUFFERED=1 python my_script.py &gt; log.txt
or
export PYTHONUNBUFFERED=1
python my_script.py &gt; log.txt

