Open NickMortimer opened 4 years ago
I've run into similar errors using xesmf in parallel applications, and it has usually been an issue with the regridder files being stored on disk. You might solve this by keeping the weight file and setting reuse_weights to True.
Any updates on the new API that makes use of in-memory storage for regridder weights?
I'd be interested in the in-memory storage for regridder weights too, as I'm running into the 545 error as well. My use case is regridding ~50 CMIP climate model fields that exist on all different grids to a common grid. Was trying to use dask.delayed to set up the ~50 calls to a regridding function (that creates an xesmf regridder and regrids) and dask.compute to then do all the regridding but it's a no go.
I tested with:
def my_regrid_func( xarraydataset, dst_grid ) regridder=xe.regridder( xarraydataset, dst_grid, 'bilinear' ) var_regrid=regridder( xarraydataset[ 'var' ] ) outDS=xr.Dataset( { var : var_regrid } ) outDS.to_netcdf( path )
result1=dask.delayed( my_regrid_func )( xarraydataset1, dst_grid ) dask.compute( result1 )
result2=dask.delayed( my_regrid_func )( xarraydataset2, dst_grid ) dask.compute( result2 )
If there's a solution for embarrassingly parallel xesmf/dask regridding that I haven't found yet, please advise thanks
Check out the new pangeo-data fork of this package, which has a number of updates including in-memory weights storage.
Same problem here. I am using xarray to read very large files from model output. I created a custom generator to read one time step at a time, regrid and feed it to a NN model. First time around works fine, second time I get this error:
File "/discover/nobackup/dbarahon/bin/conda/envs/tf_keras/lib/python3.8/site-packages/ESMF/interface/cbindings.py", line 528, in ESMP_GridCreate1PeriDim raise ValueError('ESMC_GridCreate() failed with rc = '+str(rc)+'. '+
These are the relevant parts of the code:
def train_gen(dts_per_epoch):
st = 0
epoch = 1
while True:
if st < 1:
X, y, blcks = get_dts(print_files = True)
st += 1
b = np.random.randint(0, blcks-1, 1) # select a random block of size batch size
print ('_block', b, '_')
xb = Xall.data.blocks[b]
xb1 = xb.compute()
xb2 = np.asarray(xb1)
yb = yall.data.blocks[b]
yb1 = yb.compute()
yb2 = np.asarray(yb1)
# print (yb2.shape)
yield( xb2, yb2)
xb2 = []
yb2 = []
print('st_',st)
if st > dts_per_epoch:
st = 0
def get_dts():
....
lat= dat_in['lat'].values
lon = dat_in['lon'].values
grid_out = xr.Dataset({'lat': (['lat'], lat ),
'lon': (['lon'], lon),
})
regridder = xe.Regridder(Wc, grid_out , 'bilinear', filename='regrid.nc', periodic=True, reuse_weights=True)
y = regridder(Wc)
...
I've run into similar errors using xesmf in parallel applications, and it has usually been an issue with the regridder files being stored on disk. You might solve this by keeping the weight file and setting reuse_weights to True.
Set reuse_weights = True
do not solve this problem completely , it also raises same error sometimes.
Also i install pangeo-data fork
and this problem still exist.
This problem really bother me, cause both of dask.distributed
cluster and xesmf
are all effective tools i want use.
I'm trying to interpolate a section from a curvilinear grid. I'm running an acoustic transmission loss model and need to extract sections from a model at differing bearings from a point. I've written my code as an xarray accessor.
If I have a dask cluster with 1 thread per worker all is good. If I have multiple threads then the code executes first time correctly then second or third time I get:
I known this is probably not the usual use case for this package but it works nicely. Any thoughts on how to just interplate along a line would also be greatly received.