Docker build takes very long and then getting canceled

When trying to build with Automated Builds it takes a very long time and then getting canceled.
Same if I build on my local desktop it takes 20-30 mins.

Last part of the build log from the automated build.


[ 81%] Building HIPCC object caffe2/CMakeFiles/torch_hip.dir/__/aten/src/THH/generated/torch_hip_generated_THHTensorSortBFloat16.hip.o

[ 81%] Building HIPCC object caffe2/CMakeFiles/torch_hip.dir/__/aten/src/THH/generated/torch_hip_generated_THHTensorTopKBFloat16.hip.o

Build canceled.