-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chunks? #257
Comments
Hi Jody! Thanks for uncovering a bug. The chunks option doesn't currently work and should not be there. We should remove it. IMO, there is no point in having chunks that do not align with how the data are laid out on disk. For standard singlecpuio MDS files, I think the best we could hope for is to have an option for chunking the vertical dimension (as currently done in the llcreader module), because we know how to seek within a 3D file to extract a particular vertical slice without loading the whole file into memory. This is feasible and a PR in this direction would be welcome. Another option would be to turn off singlecpuio and work on #28. Note you can always rechunk your dataset, e.g. ds = ds.chunk({'YC':10, 'YG':10}) However, this creates a new layer in your task graph, rather than changing the size of the initial read chunks. |
It seems #28 would be the best approach because then I assume reading and chunking could be multi-processor. I'm not really up on how dask works, but the end goal here was a simple slice at constant Y: ds = ds.isel(YC=200, YG=200, time=-1)
ds.to_netcdf('./SliceMid.nc', engine='netcdf4') Can dask/xarray realize that it would only need to read the tiles at YC/YG=200? Thanks! |
Dask lazily maps a function call to a chunk. The function is expected to return a numpy array with the expected shape and dtype. In this case Xmitgcm provides the function, which is ultimately Lines 310 to 311 in 4a9c748
The actual reading happens here: Lines 361 to 368 in 4a9c748
The problem is that there is no easy way to write a function to return a "simple slice at constant Y", because the data are not contiguous on disk. You can't make a call to Changing the on-disk chunk structure of your data to support different access patterns is what we created rechunker for. |
If I do
I get
This is great. However, to save memory I thought I could chunk:
fails with
Does chunking work or should I just not bother? I just spent a couple hours chasing down a job abruptly terminating, when I finally figured out that it was simply running out of memory.
The text was updated successfully, but these errors were encountered: