Cannot build PyTorch 2.3.1 with CUDA 12.9 on WSL2 (Ubuntu 22.04) — Missing nvToolsExt despite cuda-nvtx-12-9 installed

No, I would not recommend trying to build old PyTorch releases with newer CUDA toolkits as needed changes might not have landed as can be seen in your error message.