-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
segmentation fault with open_mfdataset
#444
Comments
Oh my, that's bad! Can you experiment with the It would be also be helpful to report the dtypes of the arrays that trigger failure in |
Unfortunately I can't use
Funny thing is when I'm adding these print statements and so on I get some traceback from Python (some times). Without them I would only get segmetation fault with no additional information. For example, just now, after introducing these edit: oh yeah... this is a funny thing. If I do |
Another backend to try would be That might help us identify if this is a netCDF4-python bug. I am also baffled by how inserting |
Just tried edit: I was right... it's actually the |
do you have an example file? this might also be your HDF5 install.... |
@shoyer asked me to chime in in case this is an issue with dask. One thing to try would be to remove multi-threading from the equation. I'm not sure how this would affect things but it's worth a shot. >>> import dask
>>> from dask.async import get_sync
>>> dask.set_options(get=get_sync) # use single-threaded scheduler by default
>>> ... do work as normal |
Alternatively can we try doing the operations that xray would do manually and see if one of them triggers something? One could also try
|
So I just tried @mrocklin's idea with using single-threaded stuff. This seems to fix the segmentation fault, but I am very curious as to why there's a problem with working in parallel. I tried two different hdf5 libraries (I think version 1.8.13 and 1.8.14) but I got the same segmentation fault. Anyway, working on a single thread is not a big deal, I'll just do that for the time being... I already tried @shoyer, the files are not the issue here, they're the same ones I provided in #443. Question: does the hdf5 library need to be built with parallel support (mpi or something) maybe?... thanks guys |
There was a similar problem with PyTables, which didn't support concurrency We could repeat this treatment more generally without much trouble to force
|
Of course, concurrent access to HDF5 files works fine on my laptop, using Anaconda's build of HDF5 (version 1.8.14). I have no idea what special flags they invoked when building it :). That said, I have been unable to produce any benchmarks that show improved performance when simply doing multithreaded reads without doing any computation (e.g., Given these considerations, it seems like we should use a lock when reading data into xray with dask. @mrocklin we could just use |
Oh, I didn't realize that that was built in already. Sounds like you could
|
I have a tentative fix (adding the threading lock) in #446 Still wondering why multi-threading can't use more than one CPU -- hopefully my h5py issue (referenced above) will get us some answers. |
Just merged the fix to master. @razvanc87 if you could try installing the development version, I would love to hear if this resolves your issues. |
@razvanc87 What version of h5py were you using with h5netcdf? @andrewcollette suggests (h5py/h5py#591 (comment)) that h5py should already have the lock that fixes this issue if you were using h5py 2.4.0 or later. |
Well... I have a couple of remarks to make. After some more thought about this it might have been all along my fault. Let me explain. I have this machine at work where I don't have administrative privileges so I decided to give |
OK... as a follow-up, I did some tests and with
This is simple to solve.. just have every edit: boy... there are some differences between these packages (
I didn't put the full error cause I don't think it's relevant. Anyway, needless to say... edit2: so I was going through the posts here and now I saw you addressed this issue using that |
Thanks for your help debugging! I made a new issue for ascii attributes handling: #451 This is one case where Python 3's insistence that bytes and strings are different is annoying. I'll probably have to decode all bytes type attributes read from h5netcdf. How do you trigger the seg-fault with netcdf4-python? Just using |
Yes, I'm using the same files that I once uploaded on Dropbox for you to play with for #443. I'm not doing anything special, just passing in the glob pattern to |
Ah, I think I know why the seg faults are still occuring. By default, @mrocklin maybe |
The library itself is not threadsafe? What about on a per-file basis? |
Per file basis ( |
@andrewcollette could you comment on this for h5py/hdf5? @mrocklin based on my reading of Andrew's comment in the h5py issue, this is indeed the case. |
@razvanc87 netcdf4 and h5py use the same HDF5 libraries, but have different bindings from Python. H5py likely does a more careful job of using its own locks to ensure thread safety, which likely explains the difference you are seeing (the attribute encoding is a separate issue). |
@shoyer, there are basically two levels of thread safety for HDF5/h5py. First, the HDF5 library has an optional compile-time "threadsafe" build option that wraps all API access in a lock. This is all-or-nothing; I'm not aware of any per-file effects. Second, h5py uses its own global lock on the Python side to serialize access, which is only disabled in MPI mode. For added protection, h5py also does not presently release the GIL around reads/writes. |
I think this issue can be closed, after some digging and playing with different |
@razvanc87 I've gotten a few other reports of issues with multithreading (not just you), so I think we do definitely need to add our own lock when accessing these files. Misconfigured hdf5 installs may not be so uncommon. |
This is super strange. Does anyone have any idea why a segmentation fault might be happening here?
I stay it's strange because I ended up tracking down the bug to
xray.core.ops.array_equiv
. I have no idea what's going on, but by mistake I found out that if I introduceisnull(arr1 & arr2)
just before thereturn
statement then I don't get the error any more... So myxray.core.ops.array_equiv
is now:Thanks...
The text was updated successfully, but these errors were encountered: