Fixed use of gpu in multi-epoch and improved memory efficiency.