How can I resolve this build issue with libtorch

I’ve run USE_CUDA=ON BUILD_SHARED_LIBS=OFF python setup.py build, and also tried make local, but when it gets to building Caffe2, I get:

[1/625] Building CUDA object caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/ATen/native/transformers/cuda/flash_attn/kernels/flash_bwd_hdim160_fp16_sm80.cu.o
FAILED: caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/ATen/native/transformers/cuda/flash_attn/kernels/flash_bwd_hdim160_fp16_sm80.cu.o 
/usr/local/cuda/bin/nvcc -forward-unknown-to-host-compiler -DAT_PER_OPERATOR_HEADERS -DCPUINFO_SUPPORTED_PLATFORM=1 ...

The command prints out “nvcc fatal : Could not open output file caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/ATen/native/transformers/cuda/flash_attn/kernels/flash_bwd_hdim128_bf16_sm80.cu.o.d”, and in fact caffe2/CMakeFiles doesn’t exist at all.

Came across the same error, found a fix here: Build consumes 32GB RAM triggers OOM crash when compiling CUDA object · Issue #111526 · pytorch/pytorch · GitHub