faceswap icon indicating copy to clipboard operation
faceswap copied to clipboard

How to prevent model corruption due to remote server shtutdown

Open flipflopbboi opened this issue 8 years ago • 3 comments

Hello I am currenlty training on an iPython notebook running on a remote server. The server sometimes shuts down unexpectedly due to timeout or other reasons. Note that I load my training data to the remote machine's disk for speed, while the models are stored in my clould drive (mounted via FUSE).

This setup generally works OK and I can do re-training i.e. I can provide an exception to the train.py script (by clicking the 'stop' button on the executing notebook shell) to stop execution gracefully and convert/resume at a later time. To enable this functionality (note that I cannot provide a KeyboardInterrupt in an IPython notebook) I have modified the code in train.py to save upon an Exception:

except Exception as e:
    print('*** Exception: {}'.format(e))
    model.save_weights()
    print('Saved model weights and exited.')
    exit(0)

The problem is that when the server crushes in an uncontrolled manner mid-training, I get the following error when trying to resume training of the partially trained model:

Failed loading existing training data.
Unable to open file (file signature not found)
Loading Trainer from Model_Original plugin...

In this case, the train.py starts training from scratch (over-writing my corrupt model) with loss functions around 0.23.

My questions are:

  1. Why exactly does this happen? have I misunderstood something maybe and it is a case of something else being changed/corrupted or missing?
  2. Is there a way to fix a model that has been quit mid-training and gives the Failed loading existing training data?
  3. Is there a way to keep periodic backups of the models i.e. instead of simply saving them in place, copying them to some other place?

flipflopbboi avatar Feb 17 '18 16:02 flipflopbboi

In Linux there is cron. I used that and .sh to save my models every hour. I don't know much about IPython notebook though.

Deadfishzzway avatar Feb 18 '18 04:02 Deadfishzzway

@flipflopbboi is #227 ok to solve this? Please add your review there, and continue discussion there...

Clorr avatar Mar 01 '18 11:03 Clorr

Try screen tool,works great on me! 1.sudo apt install screen 2.screen -S name 3.Run the training ,ctl + a then press d 4.if you want to see the progress,screen -r -d

parkourcx avatar Apr 21 '18 07:04 parkourcx