peterjc123:

If you want to build with the VS generator, then you should probably set CMAKE_GENERATOR, otherwise, the Ninja generator will be used and you don’t need to set any one of them.


I do not remember exactly what happened, but I build with the VS generator, since Ninja had some issues for me.
I reinstalled the latest Visual Studio Community and tried to build using the fix you provided in your first reply. However, after approximately 3 hours, the build errors out again. I think these are the relevant error messages in CMakeError.log:

C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\CMakeFiles\CMakeTmp\src.c(6,13): error C2065: "asm": undeclared identifier [C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\CMakeFiles\CMakeTmp\cmTC_e23a0.vcxproj]

C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\CMakeFiles\CMakeTmp\src.c(6,13): error C2143: Syntax error: Missing ";" infront of "volatile" [C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\CMakeFiles\CMakeTmp\cmTC_e23a0.vcxproj]



Source file was:
#include <stdint.h>
      static inline void cpuid(uint32_t *eax, uint32_t *ebx,
                               uint32_t *ecx, uint32_t *edx)
      {
        uint32_t a = *eax, b, c = *ecx, d;
        asm volatile ( "cpuid" : "+a"(a), "=b"(b), "+c"(c), "=d"(d) );
        *eax = a; *ebx = b; *ecx = c; *edx = d;
      }
      int main() {
        uint32_t a,b,c,d;
        cpuid(&a, &b, &c, &d);
        return 0;
      }

Based on the command prompt output, the problem seems to be related to gloo:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(
241,5): error MSB8066: Der benutzerdefinierte Build für "C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\third_party\
gloo\gloo\cuda.cu;C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\third_party\gloo\gloo\cuda_private.cu" wurde mit de
m Code 1 beendet. [C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\third_party\gloo\gloo\gloo_cuda.vcxproj]
...

"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\install.vcxproj" (Standardziel) (1) ->
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\ALL_BUILD.vcxproj" (Standardziel) (3) ->
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\caffe2\caffe2_pybind11_state.vcxproj" (Standardziel) (18) ->
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\caffe2\torch.vcxproj" (Standardziel) (26) ->
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\caffe2\torch_cuda.vcxproj" (Standardziel) (37) ->
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\third_party\gloo\gloo\gloo_cuda.vcxproj" (Standardziel) (39) -
>
(CustomBuild Ziel) ->
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.target
s(241,5): error MSB8066: Der benutzerdefinierte Build für "C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\third_part
y\gloo\gloo\cuda.cu;C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\third_party\gloo\gloo\cuda_private.cu" wurde mit
dem Code 1 beendet. [C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\third_party\gloo\gloo\gloo_cuda.vcxproj]

I do not understand what gloo does, but could it help to just set USE_GLOO=0, and would this in any way affect the build?
On another note, I am still missing the following files (as ptrblck already pointed out):

glog/stl_logging.h
pthread.h
mpi.h
cpuid.h
execinfo.h

Would you confirm that this is not problematic for the build / later use?