Limit the memory and CPU of Bazel build to avoid crashing the runner (#92056)
I'm seeing quite a number of runner errors "i-NUMBER lost communication with the server. Verify the machine is running and has a healthy network connection. Anything in your workflow that terminates the runner process, starves it for CPU/Memory, or blocks its network access can cause this error" with Bazel build and test job, i.e. https://hud.pytorch.org/hud/pytorch/pytorch/master/1?per_page=50&name_filter=bazel
The job runs on normal `linux.2xlarge` runner. As the error doesn't occur with any other jobs running on the same type of runner with the exception of XLA. I suspect that this is due to a resource constraint crashing the runner. So this PR sets a limit to the amount of memory and CPU and bazel can use. Even if bazel crashes, i.e. with OOM error, it's still better than crashing the whole runner and losing all the logs.
Example failures:
* https://hud.pytorch.org/pytorch/pytorch/commit/33e3c9ac679d95f28b2486ceea14188caa191d5c
Pull Request resolved: https://github.com/pytorch/pytorch/pull/92056
Approved by: https://github.com/ZainRizvi