I can't figure out why my script stops

Your code is essentially unreadable because it has lost the indentation. Please see the ‘Block code formatting’ and ‘Automatic Code Styling’ sections here to better understand how you post code on discourse. Or have it posted somewhere where you know how to post & share code, such as Github’s Gist or other code snippet site, and link to it.

Also, this is clearly not a Jupyter problem if you get essentially the same result running it without JupyterLab involved. Please seek help in places more appropriate down the road. It sounds like a memory problem since you get farther in the case of having less overhead without Jupyter. If that is the case, then refactoring your code to have less in memory at any one time might be one way to adjust it. Another option would be to split up your sets and combine results later. Or you can try running it somewhere with more memory.

2 Likes