Trouble building and installing pytorch

I am trying to build pytorch for use with CUDA 12.
While attempting the command: python setup.py install I get 5 instances of the following error:
fatal error C1189: #error: This file was generated by an older version of protoc which is (compil
ing source file D:\Programming\pytorchSetup\build\caffe2\proto\caffe2.pb.cc) [D:\Programming\pytorchSetup\build\caffe2\proto\Caffe2_PROTO.vcxproj]

I then attempted installation using the pip install {path to pytorch local} command which ran for a long time then failed, this is the end of the log:
[5860/6367] Building CUDA object caffe2\CMakeFiles\cuda_vectorized_test.dir__\aten\src\ATen\test\cuda_vectorized_test.cu.obj
cuda_vectorized_test.cu

  tmpxft_0000837c_00000000-7_cuda_vectorized_test.cudafe1.cpp

  [5861/6367] Building CUDA object caffe2\CMakeFiles\torch_cuda.dir\__\aten\src\ATen\native\transformers\cuda\flash_attn\fmha_bwd_hdim64.cu.obj
  fmha_bwd_hdim64.cu

  tmpxft_000064a0_00000000-7_fmha_bwd_hdim64.cudafe1.cpp

  [5862/6367] Building CUDA object caffe2\CMakeFiles\torch_cuda.dir\__\aten\src\ATen\native\cuda\Unique.cu.obj
  Unique.cu

  tmpxft_0000755c_00000000-7_Unique.cudafe1.cpp

  ninja: build stopped: subcommand failed.
  -- Building version 2.0.0a0+git0765dbc
  cmake -GNinja -DBUILD_PYTHON=True -DBUILD_SPLIT_CUDA=1 -DBUILD_TEST=True -DCMAKE_BUILD_TYPE=Release -DCMAKE_INCLUDE_PATH=D:\Programming\mkl\include -DCMAKE_INSTALL_PREFIX=D:\Programming\pytorch\torch -DCMAKE_PREFIX_PATH=C:\Python310\Lib\site-packages -DJAVA_HOME=C:\Program Files\Java\jdk-14.0.1 -DNUMPY_INCLUDE_DIR=C:\Users\Connor\AppData\Local\Temp\pip-build-env-iut6kxu7\overlay\Lib\site-packages\numpy\core\include -DPYTHON_EXECUTABLE=C:\Python310\python.exe -DPYTHON_INCLUDE_DIR=C:\Python310\Include -DPYTHON_LIBRARY=C:\Python310/libs/python310.lib -DTORCH_BUILD_VERSION=2.0.0a0+git0765dbc -DUSE_NUMPY=True D:\Programming\pytorch
  cmake --build . --target install --config Release
  [end of output]

Thanks for your help!

Just to add onto this, when I tried to build and install pytorch using pip install (local pytorch repo), if I used max jobs = 1. It got the following error.
fatal error C1189: #error: Macro clash with min and max – define NOMINMAX when compiling your program on Windows

I have realized this is definitely not in the right category, not sure if I can move it though. Apologies.