I've been working on a machine learning program. When it runs for a few minutes my computer gets very hot. Is there a way to limit the amount of pressure it's putting on the CPU?
IMO, this should not be done in the program itself, and it most likely can’t be done reliably. Programs should use whatever resources are available. It is more of a system concern. What you want can be achieved reliably using either a tool such as cpulimit, or a container technology such as Docker.