Unfortunately this is not a question that can be answered from an Azure perspective, but from your specific OS or possibly Spyder. There should be no difference in running this on a local computer vs the cloud.
I would start by verifying that your OS has access to that much memory (Task Manager in Windows, or 'free -h' in Linux.
If you are not using enough memory, it will usually require an adjustment to your code, or to a setting within the OS or Spyder.