You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Concurrent acces with multiple processes using open_mfdataset #2494
First: thanks to the developers for this amazing xarray library ! Great piece of work !
Here comes my troubles:
I run several (about 500) independant processes (dask distributed) that need simultaneous reading (only) access to a same (group of) netcdf files. I only pass the files-path strings to the processes to avoid pickling a netcdf python-object (issue).
but it leads to typical errors for many concurrent access that fail... : Invalid id or Exception: CancelledError("('mul-484a58bf5830233021e08456b45eb60d', 0, 0)",), ...
I was using netCDF4 module with parallel option set to True, when playing with a single netcdf file and it was running fine:
Parallel option for open_mfdataset() seems to be dedicated to multithreaded access only. Is there somthing that can be done for multi-processes access ?
Thanks
This may be fixed if you try the development version of xarray -- we did a major refactor of xarray's handling of netCDF files, e.g., try pip install https://github.com/pydata/xarray/archive/master.zip.
To clear a few things up, the parallel option in netCDF4.Dataset is not the same as the parallel option in xarray.opne_mfdataset. In xarray, that option is meant to help speed up the time it takes to open many files at once. If you are using dask distributed, this should be done using that scheduler.
If you are only seeing thread parallelism in the open_mfdataset(..., parallel=True) call, I would start by looking at your dask distributed setup.
Can you try this workflow with and without the parallel option and report back:
@jhamman I was aware of the difference between the two parallel options. I was thus wondering if I could pass a parallel option to the netcdf4 library via the open_mfdataset() call. I tried to change the engine to netcdf4 and added the backend_kwarg : backend_kwargs={'parallel':True}
but I get the same error.
I 'll try the suggestion of Stephan to see how it behaves and I will report back.
Thanks
Hi all,
I finally figured out my problem. On each independent process xr.open_mfdataset() seems to naturally try to do some multi-threaded access (even without parallel option ?). Each node of my cluster was configured in such a way that multi-threading was possible (my mistake). Here was my yaml config file used by PBSCluster()
I tough that the parallel=True option was to enable parallelized access for my independent process. It actually enable parallelized access for possible threads of each process.
Now, I have removed parallel=True from xr.open_mfdataset() call and ensure 1 thread by process by changing my config file:
Activity
shoyer commentedon Oct 19, 2018
This may be fixed if you try the development version of xarray -- we did a major refactor of xarray's handling of netCDF files, e.g., try
pip install https://github.com/pydata/xarray/archive/master.zip.jhamman commentedon Oct 19, 2018
To clear a few things up, the parallel option in
netCDF4.Datasetis not the same as the parallel option inxarray.opne_mfdataset. In xarray, that option is meant to help speed up the time it takes to open many files at once. If you are using dask distributed, this should be done using that scheduler.If you are only seeing thread parallelism in the
open_mfdataset(..., parallel=True)call, I would start by looking at your dask distributed setup.Can you try this workflow with and without the parallel option and report back:
Provided that you are setting up distributed to use multiple processes, you should get parallelism from multiple processes in this case.
lanougue commentedon Oct 22, 2018
@jhamman I was aware of the difference between the two parallel options. I was thus wondering if I could pass a parallel option to the netcdf4 library via the open_mfdataset() call. I tried to change the engine to netcdf4 and added the backend_kwarg :
backend_kwargs={'parallel':True}but I get the same error.
I 'll try the suggestion of Stephan to see how it behaves and I will report back.
Thanks
lanougue commentedon Oct 26, 2018
Hi all,
I finally figured out my problem. On each independent process xr.open_mfdataset() seems to naturally try to do some multi-threaded access (even without parallel option ?). Each node of my cluster was configured in such a way that multi-threading was possible (my mistake). Here was my yaml config file used by PBSCluster()
I tough that the parallel=True option was to enable parallelized access for my independent process. It actually enable parallelized access for possible threads of each process.
Now, I have removed parallel=True from xr.open_mfdataset() call and ensure 1 thread by process by changing my config file:
Thanks again for your help