Solved by ptrblck in post #2 
              
              
                I’m not sure how your new optimizer is defined, but e.g. LBFGS (which also requires a closure) can be memory intensive as stated in the docs: 

This is a very memory intensive optimizer (it requires additional  param_bytes * (history_size + 1)  bytes). If it doesn’t fit in memory try reducing the hi…