Build pytorch from source on Windows 10 (CUDA 10.0)

Yann: <p>Hello,</p>
<p>I am trying to build pytorch from source on Windows 10 but I keep running into compiling errors.</p>
<p>I have been reading many resources on the Internet and did what I believed was supposed to work on my system (GeForce 780m):</p>
<ul>
<li>Installed VS2017 with the “VC++ 2017 version 15.6 v14.13 toolset” (C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128)</li>
<li>Installed CUDA 10.0 with visual studio integration (and everything ticked under cuda computing toolkit)</li>
<li>Copied the cudnn-10.0-windows10-x64-v7.6.5.32 files in the relevant CUDA subdirectories</li>
<li>Created a conda environment with python 3.7.9</li>
<li>Activated the conda environment</li>
<li>Did the following:</li>
</ul>
<pre><code class="lang-bash">conda install git
conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses

git clone --recursive https://github.com/pytorch/pytorch
cd pytorch

set CMAKE_GENERATOR=Ninja
set CC=cl.exe
set CXX=cl.exe
set CUDAHOSTCXX=
set DISTUTILS_USE_SDK=1
set CMAKE_GENERATOR_TOOLSET_VERSION=14.13
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=%CMAKE_GENERATOR_TOOLSET_VERSION%
python setup.py build --cmake
python setup.py install
</code></pre>
<p>However after running for a while, the</p>
<pre><code class="lang-bash">python setup.py build --cmake
</code></pre>
<p>command fails with the following output:</p>
<pre><code class="lang-auto">(...)
Remarque : inclusion du fichier :   ..\c10/util/Half-inl.h
Remarque : inclusion du fichier :  ..\cmake\..\third_party\googletest\googletest\include\gtest/gtest.h
Remarque : inclusion du fichier :   ..\cmake\..\third_party\googletest\googletest\include\gtest/internal/gtest-internal.h
Remarque : inclusion du fichier :    ..\cmake\..\third_party\googletest\googletest\include\gtest/internal/gtest-port.h
Remarque : inclusion du fichier :     C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\algorithm
Remarque : inclusion du fichier :     ..\cmake\..\third_party\googletest\googletest\include\gtest/internal/gtest-port-arch.h
Remarque : inclusion du fichier :     ..\cmake\..\third_party\googletest\googletest\include\gtest/internal/custom/gtest-port.h
Remarque : inclusion du fichier :     C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\direct.h
Remarque : inclusion du fichier :     C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\io.h
Remarque : inclusion du fichier :      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\corecrt_io.h
Remarque : inclusion du fichier :    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\iomanip
Remarque : inclusion du fichier :     C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\xlocmon
Remarque : inclusion du fichier :     C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\xloctime
Remarque : inclusion du fichier :      C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\ctime
Remarque : inclusion du fichier :       C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\time.h
Remarque : inclusion du fichier :    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\map
Remarque : inclusion du fichier :     C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\xtree
Remarque : inclusion du fichier :    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\set
Remarque : inclusion du fichier :    ..\cmake\..\third_party\googletest\googletest\include\gtest/gtest-message.h
Remarque : inclusion du fichier :    ..\cmake\..\third_party\googletest\googletest\include\gtest/internal/gtest-filepath.h
Remarque : inclusion du fichier :     ..\cmake\..\third_party\googletest\googletest\include\gtest/internal/gtest-string.h
Remarque : inclusion du fichier :    ..\cmake\..\third_party\googletest\googletest\include\gtest/internal/gtest-type-util.h
Remarque : inclusion du fichier :   ..\cmake\..\third_party\googletest\googletest\include\gtest/gtest-death-test.h
Remarque : inclusion du fichier :    ..\cmake\..\third_party\googletest\googletest\include\gtest/internal/gtest-death-test-internal.h
Remarque : inclusion du fichier :   ..\cmake\..\third_party\googletest\googletest\include\gtest/gtest-param-test.h
Remarque : inclusion du fichier :    ..\cmake\..\third_party\googletest\googletest\include\gtest/internal/gtest-param-util.h
Remarque : inclusion du fichier :     C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\iterator
Remarque : inclusion du fichier :     ..\cmake\..\third_party\googletest\googletest\include\gtest/internal/gtest-linked_ptr.h
Remarque : inclusion du fichier :      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\assert.h
Remarque : inclusion du fichier :     ..\cmake\..\third_party\googletest\googletest\include\gtest/gtest-printers.h
Remarque : inclusion du fichier :      ..\cmake\..\third_party\googletest\googletest\include\gtest/internal/custom/gtest-printers.h
Remarque : inclusion du fichier :    ..\cmake\..\third_party\googletest\googletest\include\gtest/internal/gtest-param-util-generated.h
Remarque : inclusion du fichier :   ..\cmake\..\third_party\googletest\googletest\include\gtest/gtest_prod.h
Remarque : inclusion du fichier :   ..\cmake\..\third_party\googletest\googletest\include\gtest/gtest-test-part.h
Remarque : inclusion du fichier :   ..\cmake\..\third_party\googletest\googletest\include\gtest/gtest-typed-test.h
Remarque : inclusion du fichier :   ..\cmake\..\third_party\googletest\googletest\include\gtest/gtest_pred_impl.h
Remarque : inclusion du fichier :    ..\cmake\..\third_party\googletest\googletest\include\gtest/gtest.h
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "setup.py", line 724, in &lt;module&gt;
    build_deps()
  File "setup.py", line 317, in build_deps
    cmake=cmake)
  File "C:\Users\Yann\pytorch\tools\build_pytorch_libs.py", line 62, in build_caffe2
    cmake.build(my_env)
  File "C:\Users\Yann\pytorch\tools\setup_helpers\cmake.py", line 346, in build
    self.run(build_args, my_env)
  File "C:\Users\Yann\pytorch\tools\setup_helpers\cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "C:\Users\Yann\anaconda3\envs\pytorch\lib\subprocess.py", line 363, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '8']' returned non-zero exit status 1.
</code></pre>
<p>Do you have any clue of why this fails please? Thank you in advance.</p>

Kasirat_Kasfi: <p>Hi I am also trying to build from source but failing, have you been able to solve your issue?</p>