Too many files open
import PIL as Image
Image.fromarray(cv2.imread(link, cv2.IMREAD_GRAYSCALE))


I'm currently trying to complete a project but I'm constantly getting too many files open error on my linux GPU server which crashes the server.

I'm loading 3 images for CNN classification using the code as shown above. Anyone facing the same problem have a solution to this?

Thank you.

Try switching to the file strategy system by adding this to your script

import torch.multiprocessing
torch.multiprocessing.set_sharing_strategy('file_system')

