Despite plt.ioff()
I can't save figures on headless AWS instance. I am using the following code
title = 'Losses'
plt.ioff()
plt.figure(1)
plt.plot(losses, 'r^', label='train')
plt.plot(val_losses, 'g^', label='validate')
plt.legend(loc='upper left')
plt.title(title)
plt.savefig(os.path.join(target_directory, 'losses.png'))
How to overcome?
UPDATE
Writing
import matplotlib
matplotlib.use('Agg')
at the very beginning of a script causes warning
This call to matplotlib.use() has no effect because the backend has already been chosen; matplotlib.use() must be called before pylab, matplotlib.pyplot, or matplotlib.backends is imported for the first time.
UPDATE 2
Placing .matplotlibrc
in current directory with the following content
backend : agg
also does not help