This issue usually occurs when the chosen configuration doesn't have enough memory allocated.
For model training you can define this under the Design tab in Runtime environment. You can try to gradually increase this. The default is 4 GB and you can try to move to 8 GB and retry. If that still fails try with16 GB.
The other way to reduce memory usage for some models is to reduce parallelism for the algorithm. The default is 4 for parallelism.
You can try to change it to 2 and 16 GB container and then check if this is sufficient.