Shisho_Sama:

I could build the libs both MT and MD using the normal cmake way(setup.py build --cmake-only)


How did you build for /MT?



 Shisho_Sama:

I couldnt set DISTUTILS_USE_SDK=1 as doing so would result in the following error :


How you activated the VC shell more than once?
Let’s continue with your first code block. Would you please try the following commands?
set PYTORCH_ROOT=C:\pytorch

cd %PYTORCH_ROOT%
set BUILD_SHARED_LIBS=OFF
for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version [15^,16^) -products * -latest -property installationPath`) do call "%i\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=14.27
set CL=/DFBGEMM_STATIC#1
python tools\build_libtorch.py