The screenshot shows a MemoryError and the EOFError might just be the following error message triggered by the original one. Check if you are running our of memory and if so, reduce the batch size or use lazy loading if not already applied.
PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier