Skip to content

Commit

Permalink
LSsurf/smooth_xytb_fit.py: try to catch out-of-memory errors in the f…
Browse files Browse the repository at this point in the history
…itting steps, rerun if failed
  • Loading branch information
Ben Smith committed Oct 27, 2021
1 parent 5e27bf9 commit 2af8d1a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions LSsurf/smooth_xytb_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#from LSsurf.read_CS2_data import make_test_data
import copy
import sparseqr
from time import time, ctime
from time import time, ctime, sleep
from LSsurf.RDE import RDE
from LSsurf.unique_by_rows import unique_by_rows
#import LSsurf.op_structure_checks as checks
Expand Down Expand Up @@ -475,9 +475,16 @@ def iterate_fit(data, Gcoo, rhs, TCinv, G_data, Gc, in_TSE, Ip_c, timing, args,\
if args['VERBOSE']:
print("starting qr solve for iteration %d at %s" % (iteration, ctime()), flush=True)
# solve the equations
tic=time();
m0=Ip_c.dot(sparseqr.solve(Ip_r.dot(TCinv.dot(Gcoo)), Ip_r.dot(TCinv.dot(rhs))));
timing['sparseqr_solve']=time()-tic
solved=False
while not solved:
try:
tic=time();
m0=Ip_c.dot(sparseqr.solve(Ip_r.dot(TCinv.dot(Gcoo)), Ip_r.dot(TCinv.dot(rhs))));
timing['sparseqr_solve']=time()-tic
solved=True
except TypeError:
print("smooth_xytb_fit: spareqr.solve failed, probably because of memory. Retrying after 5 minutes")
sleep(300)

# calculate the full data residual
rs_data=(data.z-G_data.toCSR().dot(m0))/data.sigma
Expand Down

0 comments on commit 2af8d1a

Please sign in to comment.