PyTorch build from source on Windows

mmisiur: <p>I’m trying to build PyTorch from source on Windows 10 (as described in pytorch repo), and I’m getting an error:</p>
<pre><code class="lang-auto">Building wheel torch-1.1.0a0+542c273
-- Building version 1.1.0a0+542c273
Microsoft (R) Build Engine 15.9.21+g9802d43bc3 dla platformy .NET Framework
Copyright (C) Microsoft Corporation. Wszelkie prawa zastrzeżone.

MSBUILD : error MSB1009: Project file does not exist.
Switch: INSTALL.vcxproj
Traceback (most recent call last):
  File "setup.py", line 710, in &lt;module&gt;
    build_deps()
  File "setup.py", line 282, in build_deps
    build_dir='build')
  File "C:\Users\MarcinM\pytorch\tools\build_pytorch_libs.py", line 250, in build_caffe2
    cwd=build_dir, env=my_env)
  File "C:\Users\MarcinM\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['msbuild', 'INSTALL.vcxproj', '/p:Configuration=Release']' returned non-zero exit status 1.
</code></pre>
<p>What I’ve done:</p>
<ol>
<li>git cloned the pytorch repo</li>
<li>Installed VS 2017 15.9.9 Community with checking:
<ul>
<li>Windows 10 SDK (10.0;16299.0) for Desktop C++ [x86 i x64]</li>
<li>Version 14.11 of toolset for version 15.4 of VC++ 2017</li>
</ul>
</li>
<li>run <code>git submodule update --init --recursive</code>
</li>
<li>run <code>pip install numpy pyyaml mkl mkl-include setuptools cmake cffi typing</code>
</li>
<li>run:</li>
</ol>
<pre><code class="lang-auto">set "CUDAHOSTCXX=%VS140COMNTOOLS%..\..\VC\bin\amd64\cl.exe"
set CMAKE_GENERATOR=Visual Studio 15 2017 Win64
set DISTUTILS_USE_SDK=1
(edit:) 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.11
 
python setup.py install
</code></pre>
<p>Is it possible that the order of commands got me this error (I’ve run 4. after installing VS toolsets)?<br>
Can you help me overvcome this error?</p>
<p>Windows 10<br>
python 36<br>
cuda 9.1</p>

peterjc123: <p>You are missing one line in the steps in the official readme.md.</p>
<pre><code class="lang-auto">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.11
</code></pre>

mmisiur: <p>Peter, thanks for reply. My, bad, I forgot to include that in post, but I’ve also run it. Today I’ve made through everything in readme once again, but with no luck - the msbuild error is still there. Any other ideas?</p>

peterjc123: <p>Use <code>where msbuild</code> to locate whether it is in <code>PATH</code>. If it is not, then please add <code>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin</code> into <code>PATH</code>. (P.S. <code>Enterprise</code> here can be replaced by <code>Community</code> or <code>Professional</code>)</p>

mmisiur: <p>Yes, <code>where msbuild</code> gives me exactly</p>
<pre><code class="lang-auto">C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
</code></pre>
<p>btw I’m using <code>pip</code>, not <code>conda</code> for <code>pip install numpy pyyaml mkl mkl-include setuptools cmake cffi typing</code> ( I know that in readme the is note that conda is strongly recommended, but somehow I’m unable to set up <code>conda</code> on my machine). Maybe the problem is here?</p>

peterjc123: <p>No, conda is not the problem here. Would you please do <code>python setup.py build</code> and send the full log here. There must be some problem during the configuration of CMake.</p>

mmisiur: <p>Yes, I’ve run it and the full log is exactly like the one I provided in the question.</p>

peterjc123: <aside class="quote no-group" data-username="mmisiur" data-post="1" data-topic="40288">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mmisiur/48/10162_2.png" class="avatar"> mmisiur:</div>
<blockquote>
<p>MSBUILD : error MSB1009: Project file does not exist. Switch: INSTALL.vcxproj</p>
</blockquote>
</aside>
<p>I don’t think so. This one is apparently not the root cause. Would you please do <code>python setup.py build --cmake</code>?</p>

mmisiur: <p>Yes! That did the work, after</p>
<pre><code class="lang-auto">python setup.py build --cmake
python setup.py install
</code></pre>
<p>pytorch was finally installed.<br>
However</p>
<pre><code class="lang-auto">python
&gt;&gt;&gt; import torch
&gt;&gt;&gt; torch.cuda.is_available()
</code></pre>
<p>returns <code>False</code>. When I run <code>torch.cuda.current_device()</code> i get:<br>
<code>AssertionError: Torch not compiled with CUDA enabled</code></p>
<p>Can this be Nsight Compute issue?</p>

peterjc123: <p>Yes, may be. Please ensure CUDA and the Visual Studio extension are installed. If the env var <code>%NVTOOLSEXT_PATH%</code> exists, then it should be fine. Otherwise, please reinstall CUDA and remember to tick VS extension.</p>

mmisiur: <p>I reinstalled CUDA to 10.1, ensuring that both Nsight Compute and VS extensions are checked. Now when I try to build pytorch witch <code>python setup.py build --cmake</code> I get this error (note that some of the phrases were in polish, so I’ve translated them):</p>
<pre><code class="lang-auto">"C:\Users\MarcinM\pytorch\build\INSTALL.vcxproj" (default target) (1)-&gt;
"C:\Users\MarcinM\pytorch\build\ALL_BUILD.vcxproj" (default target) (3)-&gt;
"C:\Users\MarcinM\pytorch\build\caffe2\AlgorithmsTest.vcxproj" (default target) (4)-&gt;
"C:\Users\MarcinM\pytorch\build\caffe2\caffe2_gpu.vcxproj" (default target) (21)-&gt;
(CustomBuild target) -&gt;
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(20
9,5): error MSB6006: "cmd.exe" exited with code 1. [C:\Users\MarcinM\pytorch\build\caffe2\caffe2_gpu.vcxp
roj]

    Warnings: 3661
    Errors: 1

Czas, który upłynął: 00:32:23.65
Traceback (most recent call last):
  File "setup.py", line 710, in &lt;module&gt;
    build_deps()
  File "setup.py", line 282, in build_deps
    build_dir='build')
  File "C:\Users\MarcinM\pytorch\tools\build_pytorch_libs.py", line 264, in build_caffe2
    cwd=build_dir, env=my_env)
  File "C:\Users\MarcinM\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['msbuild', 'INSTALL.vcxproj', '/p:Configuration=Release']' returned non-zero exit status 1.
</code></pre>
<p>I’ve also made clean build, but with no success. Any other thoughts?</p>

peterjc123: <aside class="quote no-group quote-modified" data-username="mmisiur" data-post="11" data-topic="40288">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mmisiur/48/10162_2.png" class="avatar"> mmisiur:</div>
<blockquote>
<p>error MSB6006: “cmd.exe” exited with code 1.</p>
</blockquote>
</aside>
<p>Would you please run the building process inside VS (only caffe2_gpu is enough and make sure you choose Release and x64) ? Alternatively, you can use Ninja, which is quite simple to use. And then you can see the internal error.</p>
<pre><code class="lang-auto">pip install ninja
set CMAKE_GENERATOR=Ninja
</code></pre>

mmisiur: <p>Thanks, I really appreciate your commitment for this! So I’ve run this by Ninja, and it exited pretty fast. The error log is quite long:</p>
<pre><code class="lang-auto">-- The CXX compiler identification is GNU 7.2.0
-- The C compiler identification is GNU 7.2.0
-- Check for working CXX compiler: C:/Program Files/Haskell Platform/8.4.3/mingw/bin/c++.exe
-- Check for working CXX compiler: C:/Program Files/Haskell Platform/8.4.3/mingw/bin/c++.exe -- broken
CMake Error at C:/Users/MarcinM/AppData/Local/Programs/Python/Python36/Lib/site-packages/cmake/data/share/cmake-3.13/Modules/CMakeTestCXXCompiler.cmake:45 (message):
  The C++ compiler

    "C:/Program Files/Haskell Platform/8.4.3/mingw/bin/c++.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/MarcinM/pytorch/build/CMakeFiles/CMakeTmp

    Run Build Command:"C:/Users/MarcinM/AppData/Local/Programs/Python/Python36/Scripts/ninja.exe" "cmTC_42959"
    [1/2] Building CXX object CMakeFiles/cmTC_42959.dir/testCXXCompiler.cxx.obj
    FAILED: CMakeFiles/cmTC_42959.dir/testCXXCompiler.cxx.obj
    C:\PROGRA~1\HASKEL~1\847A5C~1.3\mingw\bin\C__~1.EXE    /EHa -o CMakeFiles/cmTC_42959.dir/testCXXCompiler.cxx.obj -c testCXXCompiler.cxx
    C__~1.EXE: error: /EHa: No such file or directory
    ninja: build stopped: subcommand failed.




  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:11 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Users/MarcinM/pytorch/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/MarcinM/pytorch/build/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
  File "setup.py", line 710, in &lt;module&gt;
    build_deps()
  File "setup.py", line 282, in build_deps
    build_dir='build')
  File "C:\Users\MarcinM\pytorch\tools\build_pytorch_libs.py", line 253, in build_caffe2
    my_env)
  File "C:\Users\MarcinM\pytorch\tools\build_pytorch_libs.py", line 233, in run_cmake
    check_call(cmake_args, cwd=build_dir, env=my_env)
  File "C:\Users\MarcinM\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '-GNinja', '-DBUILDING_WITH_TORCH_LIBS=ON', '-DBUILD_BINARY=False', '-DBUILD_CAFFE2_OPS=True', '-DBUILD_PYTHON=True', '-DBUILD_SHARED_LIBS=ON', '-DBUILD_TEST=True', '-DBUILD_TORCH=ON', '-DCAFFE2_STATIC_LINK_CUDA=False', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_CXX_FLAGS=  /EHa', '-DCMAKE_C_FLAGS=  /EHa', '-DCMAKE_EXE_LINKER_FLAGS=', '-DCMAKE_INSTALL_PREFIX=C:\\Users\\MarcinM\\pytorch/torch', '-DCMAKE_PREFIX_PATH=C:\\Users\\MarcinM\\AppData\\Local\\Programs\\Python\\Python36\\Lib\\site-packages', '-DCMAKE_SHARED_LINKER_FLAGS=', '-DINSTALL_TEST=True', '-DNCCL_EXTERNAL=False', '-DNUMPY_INCLUDE_DIR=C:/Users/MarcinM/AppData/Local/Programs/Python/Python36/lib/site-packages/numpy/core/include', '-DONNX_ML=False', '-DONNX_NAMESPACE=onnx_torch', '-DPYTHON_EXECUTABLE=C:/Users/MarcinM/AppData/Local/Programs/Python/Python36/python.exe', '-DPYTHON_INCLUDE_DIR=C:/Users/MarcinM/AppData/Local/Programs/Python/Python36/include', '-DPYTHON_LIBRARY=C:/Users/MarcinM/AppData/Local/Programs/Python/Python36/libs/python36.lib', '-DTHD_SO_VERSION=1', '-DTORCH_BUILD_VERSION=1.1.0a0+e5cdd94', '-DUSE_CUDA=True', '-DUSE_DISTRIBUTED=False', '-DUSE_FBGEMM=True', '-DUSE_FFMPEG=False', '-DUSE_LEVELDB=False', '-DUSE_LMDB=False', '-DUSE_MKLDNN=True', '-DUSE_NCCL=False', '-DUSE_NNPACK=True', '-DUSE_NUMPY=True', '-DUSE_OPENCV=False', '-DUSE_QNNPACK=True', '-DUSE_ROCM=False', '-DUSE_SYSTEM_EIGEN_INSTALL=OFF', '-DUSE_SYSTEM_NCCL=False', '-DUSE_TENSORRT=False', '-DMKLDNN_ENABLE_CONCURRENT_EXEC=ON', 'C:\\Users\\MarcinM\\pytorch']' returned non-zero exit status 1.
</code></pre>
<p>The folder <code>C:/Users/MarcinM/pytorch/build/CMakeFiles/CMakeTmp</code> is empty if this is any help. Also the c++.exe file is present in <code>C:\Program Files\Haskell Platform\8.4.3\mingw\bin</code>.</p>

peterjc123: <p>Oh, I’m missing these variables.</p>
<pre><code class="lang-auto">set CC=cl.exe
set CXX=cl.exe
</code></pre>

mmisiur: <p>Ok, so there is a lot of similar errors like this (I’ve also changed polish phrases):</p>
<pre><code class="lang-auto">[1624/2499] Building NVCC (Device) object caffe2/CMakeFile...en/src/ATen/native/cuda/caffe2_gpu_generated_Reduce.cu.obj
FAILED: caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/ATen/native/cuda/caffe2_gpu_generated_Reduce.cu.obj
cmd.exe /C "cd /D C:\Users\MarcinM\pytorch\build\caffe2\CMakeFiles\caffe2_gpu.dir\__\aten\src\ATen\native\cuda &amp;&amp; C:\Users\MarcinM\AppData\Local\Programs\Python\Python36\Lib\site-packages\cmake\data\bin\cmake.exe -E make_directory C:/Users/MarcinM/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/ATen/native/cuda/. &amp;&amp; C:\Users\MarcinM\AppData\Local\Programs\Python\Python36\Lib\site-packages\cmake\data\bin\cmake.exe -D verbose:BOOL=OFF -D build_configuration:STRING=Release -D generated_file:STRING=C:/Users/MarcinM/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/ATen/native/cuda/./caffe2_gpu_generated_Reduce.cu.obj -D generated_cubin_file:STRING=C:/Users/MarcinM/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/ATen/native/cuda/./caffe2_gpu_generated_Reduce.cu.obj.cubin.txt -P C:/Users/MarcinM/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/ATen/native/cuda/caffe2_gpu_generated_Reduce.cu.obj.Release.cmake"
Failed to run %VS140COMNTOOLS%../../VC/bin/amd64/cl.exe (No such file).
CMake Error at caffe2_gpu_generated_Reduce.cu.obj.Release.cmake:219 (message):
  Error generating
  C:/Users/MarcinM/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/ATen/native/cuda/./caffe2_gpu_generated_Reduce.cu.obj
</code></pre>
<p>and one last error is:</p>
<pre><code class="lang-auto">[1625/2499] Linking CXX shared module caffe2\python\caffe2_pybind11_state.cp36-win_amd64.pyd
   Creating library lib\caffe2_pybind11_state.lib and object lib\caffe2_pybind11_state.exp
pybind_state.cc.obj : warning LNK4217: locally defined symbol ?PybindAdditionRegistry@python@caffe2@@YAPEAV?$Registry@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$unique_ptr@UPybindAddition@python@caffe2@@U?$default_delete@UPybindAddition@python@caffe2@@@std@@@2@AEAVmodule@pybind11@@@c10@@XZ (class c10::Registry&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::unique_ptr&lt;struct caffe2::python::PybindAddition,struct std::default_delete&lt;struct caffe2::python::PybindAddition&gt; &gt;,class pybind11::module &amp;&gt; * __cdecl caffe2::python::PybindAdditionRegistry(void)) was imported in function "void __cdecl caffe2::python::pybind11_init_caffe2_pybind11_state(class pybind11::module &amp;)" (?pybind11_init_caffe2_pybind11_state@python@caffe2@@YAXAEAVmodule@pybind11@@@Z)
pybind_state_nomni.cc.obj : warning LNK4049: locally defined symbol ?PybindAdditionRegistry@python@caffe2@@YAPEAV?$Registry@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$unique_ptr@UPybindAddition@python@caffe2@@U?$default_delete@UPybindAddition@python@caffe2@@@std@@@2@AEAVmodule@pybind11@@@c10@@XZ (class c10::Registry&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::unique_ptr&lt;struct caffe2::python::PybindAddition,struct std::default_delete&lt;struct caffe2::python::PybindAddition&gt; &gt;,class pybind11::module &amp;&gt; * __cdecl caffe2::python::PybindAdditionRegistry(void)) was imported
pybind_state_int8.cc.obj : warning LNK4217: locally defined symbol ?BlobFetcherRegistry@python@caffe2@@YAPEAV?$Registry@VTypeIdentifier@caffe2@@V?$unique_ptr@VBlobFetcherBase@python@caffe2@@U?$default_delete@VBlobFetcherBase@python@caffe2@@@std@@@std@@$$V@c10@@XZ (class c10::Registry&lt;class caffe2::TypeIdentifier,class std::unique_ptr&lt;class caffe2::python::BlobFetcherBase,struct std::default_delete&lt;class caffe2::python::BlobFetcherBase&gt; &gt; &gt; * __cdecl caffe2::python::BlobFetcherRegistry(void)) zostal zaimportowany w funkcji "void __cdecl caffe2::python::`dynamic initializer for 'g_BlobFetcherRegistry0''(void)" (??__Eg_BlobFetcherRegistry0@python@caffe2@@YAXXZ)
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "setup.py", line 710, in &lt;module&gt;
    build_deps()
  File "setup.py", line 282, in build_deps
    build_dir='build')
  File "C:\Users\MarcinM\pytorch\tools\build_pytorch_libs.py", line 261, in build_caffe2
    cwd=build_dir, env=my_env)
  File "C:\Users\MarcinM\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '11']' returned non-zero exit status 1.
</code></pre>
<p>About <code>Failed to run %VS140COMNTOOLS%../../VC/bin/amd64/cl.exe (No such file).</code>, indeed there is no such path as <code>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\bin</code>.<br>
Maybe the path should be <code>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\cl.exe</code> as implied in <a href="https://github.com/facebookarchive/caffe2/issues/774" rel="nofollow noopener">caffe2 old repo discussion</a>?</p>
<p>Edit: I’ve changed the path to but with no luck:</p>
<pre><code class="lang-auto">Failed to run %VS140COMNTOOLS%../../VC/Tools/MSVC/14.11.25503/bin/HostX64/x64/cl.exe (No such file).
</code></pre>
<p>Which is quite weird because the file <code>cl.exe</code> is definitely there.</p>

peterjc123: <p>please try<br>
<code>set CUDAHOSTCXX=</code></p>

mmisiur: <p>Yes! That worked! Everything went well with it. Pytorch was installed, and is working with cuda. Thank you so much peterjc123!</p>
<p>For future readers, to sum up:</p>
<ol>
<li>I reinstalled drivers for CUDA, reinstalled CUDA with VS extensions and Nsight Compute (actually with everything checked), reinstaled CUDnn</li>
<li>went with</li>
</ol>
<pre><code class="lang-auto">pip install ninja
set CMAKE_GENERATOR=Ninja
set CC=cl.exe
set CXX=cl.exe
set CUDAHOSTCXX=
set DISTUTILS_USE_SDK=1
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.11
python setup.py build --cmake
python setup.py install
</code></pre>

yalamix: <p>Hello, I’m trying to build PyTorch from source on Windows, since my video card has Compute Capability 3.0. I have installed all the prerequisites and I have tried the procedure outlined <a href="https://github.com/pytorch/pytorch#from-source" rel="nofollow noopener">here</a>, but it failed. I came across this thread and attempted the same steps but I’m still unable to install PyTorch. Here is the error:</p>
<pre><code class="lang-auto">Microsoft Windows [versão 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Todos os direitos reservados.

C:\Users\César&gt;cd ..

C:\Users&gt; cd ..

C:\&gt;cd pytorch

C:\pytorch&gt;set CMAKE_GENERATOR=Ninja

C:\pytorch&gt;set CC=cl.exe

C:\pytorch&gt;set CXX=cl.exe

C:\pytorch&gt;set CUDAHOSTCXX=

C:\pytorch&gt;set DISTUTILS_USE_SDK=1

C:\pytorch&gt;for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Vis
ual Studio\Installer\vswhere.exe" -version [15^,16^) -products * -latest -proper
ty installationPath`) do call "%i\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_
ver=14.11

C:\pytorch&gt;call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\
VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=14.11
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\pytorch&gt;python setup.py build --cmake
Building wheel torch-1.6.0a0+5e0a24f
-- Building version 1.6.0a0+5e0a24f
cmake -GNinja -DBUILD_PYTHON=True -DBUILD_TEST=True -DCMAKE_BUILD_TYPE=Release -
DCMAKE_GENERATOR=Ninja -DCMAKE_INSTALL_PREFIX=C:\pytorch\torch -DCMAKE_PREFIX_PA
TH=C:\ProgramData\Miniconda3\Lib\site-packages -DJAVA_HOME=C:\Program Files\Java
\jdk1.8.0_181 -DNUMPY_INCLUDE_DIR=C:\ProgramData\Miniconda3\lib\site-packages\nu
mpy\core\include -DPYTHON_EXECUTABLE=C:\ProgramData\Miniconda3\python.exe -DPYTH
ON_INCLUDE_DIR=C:\ProgramData\Miniconda3\include -DPYTHON_LIBRARY=C:\ProgramData
\Miniconda3/libs/python37.lib -DTORCH_BUILD_VERSION=1.6.0a0+5e0a24f -DUSE_NUMPY=
True C:\pytorch
-- The CXX compiler identification is MSVC 19.11.25548.2
-- The C compiler identification is MSVC 19.11.25548.2
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
o/2017/BuildTools/VC/Tools/MSVC/14.11.25503/bin/HostX64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
o/2017/BuildTools/VC/Tools/MSVC/14.11.25503/bin/HostX64/x64/cl.exe - broken
CMake Error at C:/ProgramData/Miniconda3/Library/share/cmake-3.17/Modules/CMakeT
estCXXCompiler.cmake:53 (message):
  The C++ compiler

    "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSV
C/14.11.25503/bin/HostX64/x64/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/pytorch/build/CMakeFiles/CMakeTmp

    Run Build Command(s):C:/ProgramData/Miniconda3/Library/bin/ninja.exe cmTC_f0
8a4 &amp;&amp; [1/2] Building CXX object CMakeFiles\cmTC_f08a4.dir\testCXXCompiler.cxx.o
bj
    FAILED: CMakeFiles/cmTC_f08a4.dir/testCXXCompiler.cxx.obj
    C:\PROGRA~2\MIB055~1\2017\BUILDT~1\VC\Tools\MSVC\1411~1.255\bin\HostX64\x64\
cl.exe  /nologo /TP   "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\
include"  /DWIN32 /D_WINDOWS /GR /EHsc  /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /F
oCMakeFiles\cmTC_f08a4.dir\testCXXCompiler.cxx.obj /FdCMakeFiles\cmTC_f08a4.dir\
 /FS -c testCXXCompiler.cxx
    include
    c1xx: fatal error C1083: Não é possível abrir arquivo fonte: 'C:\Program Fil
es\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include': No such file or directory
    Gerando Código...
    ninja: build stopped: subcommand failed.





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:23 (project)


-- Configuring incomplete, errors occurred!
See also "C:/pytorch/build/CMakeFiles/CMakeOutput.log".
See also "C:/pytorch/build/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
  File "setup.py", line 740, in &lt;module&gt;
    build_deps()
  File "setup.py", line 323, in build_deps
    cmake=cmake)
  File "C:\pytorch\tools\build_pytorch_libs.py", line 59, in build_caffe2
    rerun_cmake)
  File "C:\pytorch\tools\setup_helpers\cmake.py", line 324, in generate
    self.run(args, env=my_env)
  File "C:\pytorch\tools\setup_helpers\cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "C:\ProgramData\Miniconda3\lib\subprocess.py", line 363, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '-GNinja', '-DBUILD_PYTHON=Tru
e', '-DBUILD_TEST=True', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_GENERATOR=Ninja'
, '-DCMAKE_INSTALL_PREFIX=C:\\pytorch\\torch', '-DCMAKE_PREFIX_PATH=C:\\ProgramD
ata\\Miniconda3\\Lib\\site-packages', '-DJAVA_HOME=C:\\Program Files\\Java\\jdk1
.8.0_181', '-DNUMPY_INCLUDE_DIR=C:\\ProgramData\\Miniconda3\\lib\\site-packages\
\numpy\\core\\include', '-DPYTHON_EXECUTABLE=C:\\ProgramData\\Miniconda3\\python
.exe', '-DPYTHON_INCLUDE_DIR=C:\\ProgramData\\Miniconda3\\include', '-DPYTHON_LI
BRARY=C:\\ProgramData\\Miniconda3/libs/python37.lib', '-DTORCH_BUILD_VERSION=1.6
.0a0+5e0a24f', '-DUSE_NUMPY=True', 'C:\\pytorch']' returned non-zero exit status
 1.

C:\pytorch&gt;
</code></pre>
<p>I am pretty sure everything is correctly installed. The folder “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include” exists. I have tried reinstalling the CUDA drivers with all the extensions twice and it still does not work.</p>

peterjc123: <p>Could you please show me the output of the following command in CMD: <code>set</code>?</p>

peterjc123: <p>It is probably because some environmental variables are not correctly set, like <code>INCLUDE</code> or <code>LIB</code>.</p>