I'm trying to open a hdf5 file using h5py with mpi by executing
print("Opening...")
f = h5py.File(file_path, "r", driver='mpio', comm=MPI.COMM_WORLD)
print("Done")
For some reason, this line blocks when executed in my project. I tried to create a small reproducible example without success as this line works as it should in these examples.
So there is something in my codebase that I can't track down, that causes the above-mentioned line to block.
Question: What can cause h5py.File
to block?
Note: CPU goes to 100% so mpi seems to be waiting for something...
Note2: Added some code from my codebase that doesn't help at all:
Opening the file before the if works, inside the if just blocks...
from mpi4py import MPI
import h5py
from DataProviderH5PYPool import init_pool, new_worker
import Settings
rank = MPI.COMM_WORLD.Get_rank()
task = [
"main",
"h5py_worker"
]
task = task[rank] if rank < len(task)-1 else task[-1]
print("Starting new process: {} with rank {}".format(task,rank))
def init():
# works
print(h5py.File(Settings.h5py.training[0], "r", driver='mpio', comm=MPI.COMM_WORLD)["0"][0])
if task == "main":
# blocks
# print(h5py.File(Settings.h5py.training[0], "r", driver='mpio', comm=MPI.COMM_WORLD)["0"][0])
init_pool(n=MPI.COMM_WORLD.Get_size()-1)
return True
elif task == "h5py_worker":
# works too but results in
# RuntimeError: Can't decrement id ref count (Can't close file, there are objects still open
# print(h5py.File(Settings.h5py.training[0], "r", driver='mpio', comm=MPI.COMM_WORLD)["0"][0])
new_worker()
return False
else:
raise RuntimeError("Unsupported task '{}'".format(task))
Code is executed via
mpiexec -n 2 python Test.py
or
mpiexec.mpich -n 2 python Test.py
installed both and tried them but got the same result...