RuntimeError: received 0 items of ancdata

Hi, all, I’m new to the fastai library. I have a -trained- learner, which I’m trying to use to make predictions on a validation set, which consists of 100.000 samples, via the learner.get_preds(ds_type=DatasetType.Valid) method, yielding the following exception: “RuntimeError: received 0 items of ancdata”.

I read the GH issue ( and tried the solution mentioned there resource.setrlimit(resource.RLIMIT_NOFILE, (4096, rlimit[1])), but with no success.

Is there a way I can go about this?

@lqrz I encountered the same problem when trying to generate predictions. After searching online a bit, I found this blog post Solution to RuntimeError: received 0 items of ancdata (the post is in Chinese).

I tried the second solution listed there:

Add torch.multiprocessing.set_sharing_strategy('file_system') after importing Fastai. According to the blog post, the default option file_descriptor has a limitation on the number of open files, which caused the runtime error. And this solved my problem.

I hope this helps. :wink:


Thanks. Adding torch.multiprocessing.set_sharing_strategy(‘file_system’) below fastai worked for me. In case it does not work for someone, try delete any dataframe or restart your kernel and run it again.