Error in Build Pytorch1.8 from source offline windows 10

AceYuanLI: <p>Hello everyone, I try to build Pytorch 1.8 from source offline with VS 2019 (cuda11.1,cudnn8.2).</p>
<p>My Work Steps :</p>
<p>(1) I download the source code from <a href="https://github.com/pytorch/pytorch/tree/v1.8.1" class="inline-onebox" rel="noopener nofollow ugc">GitHub - pytorch/pytorch at v1.8.1</a> (with all third party from their github).</p>
<p>(2) Install VS 2019 community (16.4.5 version).</p>
<p>(3) Install cuda11.1 , and test the command “nvcc -V” well.</p>
<p>(4) Install cudnn8.2 .</p>
<p>(5) Install anaconda and create enviroment (python==3.6) .</p>
<p>(6) Activate this enviromente and Follow the common reqiurements of <a href="https://github.com/pytorch/pytorch/tree/v1.8.1" class="inline-onebox" rel="noopener nofollow ugc">GitHub - pytorch/pytorch at v1.8.1</a> , “conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses”, the result of install is okay.</p>
<p>(7) Refer to <a href="https://github.com/pytorch/pytorch/blob/master/.jenkins/pytorch/win-test-helpers/build_pytorch.bat" rel="noopener nofollow ugc">build_pytorch.bat</a> .Then I download MKL ,MAGMA,SSCAHE,and Randomtemp.exe.</p>
<p>(8) I make a batch file script ,like the above [build_pytorch.bat].The key point lines are :<br>
" echo @“E:\build_torch\needed\bin\randomtemp.exe” “E:\build_torch\needed\bin\sccache.exe” “%CUDA_PATH%\bin\nvcc.exe” %%* &gt; “%TMP_DIR%\bin\nvcc.bat”</p>
<p>cat %TMP_DIR%\bin\nvcc.bat</p>
<p>set CUDA_NVCC_EXECUTABLE=%TMP_DIR%\bin\nvcc.bat "</p>
<p>(9) when I acitvate env and set my batch file script to build, MKL MAGMA SSCAHE could find and work,but the above 3 lines will cause that error “cuda could not found” .<br>
Because in FindCUDA.camke line 786 “execute_process(COMMAN ${CUDA_NVCC_EXECUTABLE}) “–VERSION” ”  , nvcc.bat do not work.<br>
And CMAKE will modify USE_CUDA = 0.<br>
This building result without cuda is not my target.</p>
<p>(10) Next time , I modify the above 3 lines . I just “set CUDA_NVCC_EXECUTABLE=%CUDA_PATH%\bin\nvcc.exe”.</p>
<p>(11) This time I set env vars and “python setup.py install --cmake”.<br>
Cuda could find and work.<br>
But Erros happen in about [4143/5177] :<br>
“BinaryLogicalOpsKernels.cu<br>
BinaryLogicalOpsKernels.cuninja: build stopped: subcommand failed.<br>
Traceback (most recent call last):<br>
File “setup.py”, line 818, in <br>
build_deps()<br>
File “setup.py”, line 320, in build_deps<br>
cmake=cmake)<br>
File “E:\build_torch\B14\pytorch\tools\build_pytorch_libs.py”, line 58, in build_caffe2<br>
cmake.build(my_env)<br>
File “E:\build_torch\B14\pytorch\tools\setup_helpers\cmake.py”, line 345, in build<br>
self.run(build_args, my_env)<br>
File “E:\build_torch\B14\pytorch\tools\setup_helpers\cmake.py”, line 140, in run<br>
check_call(command, cwd=self.build_dir, env=env)<br>
File “E:\Anaconda3\envs\mtorch\lib\subprocess.py”, line 311, in check_call<br>
raise CalledProcessError(retcode, cmd)<br>
subprocess.CalledProcessError: Command ‘[‘cmake’, ‘–build’, ‘.’, ‘–target’, ‘install’, ‘–config’, ‘Release’, ‘–’, ‘-j’, ‘8’]’ returned non-zero exit status 1.”</p>
<p>So I wanna know what’s wrong with my work ，please help me, many thanks!</p>

AceYuanLI: <p>This is latest collapse error in building process[4149/5117]:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/5/f/5fb7fbee8d33a88a7d798b5cd0a1d3792c7bd3b5.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/5fb7fbee8d33a88a7d798b5cd0a1d3792c7bd3b5" title="error1"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/5/f/5fb7fbee8d33a88a7d798b5cd0a1d3792c7bd3b5_2_690x388.jpeg" alt="error1" data-base62-sha1="dELxItn41vC5EEu5WBYOAJoMRuZ" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/5/f/5fb7fbee8d33a88a7d798b5cd0a1d3792c7bd3b5_2_690x388.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/5/f/5fb7fbee8d33a88a7d798b5cd0a1d3792c7bd3b5_2_1035x582.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/5/f/5fb7fbee8d33a88a7d798b5cd0a1d3792c7bd3b5_2_1380x776.jpeg 2x" data-dominant-color="6D7175"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">error1</span><span class="informations">1920×1080 326 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
and breakdown:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/b/d/bdf2c601919186b40831f6a6be7c94f71da1939a.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/bdf2c601919186b40831f6a6be7c94f71da1939a" title="error"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/b/d/bdf2c601919186b40831f6a6be7c94f71da1939a_2_690x388.jpeg" alt="error" data-base62-sha1="r6mnF5A6cFmDICEAtQxUwVqzOmm" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/b/d/bdf2c601919186b40831f6a6be7c94f71da1939a_2_690x388.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/b/d/bdf2c601919186b40831f6a6be7c94f71da1939a_2_1035x582.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/b/d/bdf2c601919186b40831f6a6be7c94f71da1939a_2_1380x776.jpeg 2x" data-dominant-color="6B6F73"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">error</span><span class="informations">1920×1080 385 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

AceYuanLI: <p>(1)Probably, I guess this error about nvcc.</p>
<p>(2)Because, before this time I set wrong env var :<br>
“set CUDAHOSTCXX=D:\Program Files\Microsoft Visual<br>
Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX64\x64\cl.exe”</p>
<p>(3)And then ,build breakdown in [4059/5117], error : “nvcc fatal : nvcc fatal : Failed to preprocess host compiler properties”</p>
<p>(4)In fact,the right way of CUDAHOSTCXX is “D:\Program Files(x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX64\x64\cl.exe”</p>
<p>(5)Next , I modified it and restarted to build.</p>
<p>break down in the above pics [4149/5117].</p>
<p>Could you give me some solutions ? Many thanks!</p>

AceYuanLI: <p><a class="mention" href="/u/peterjc123">@peterjc123</a> hi ,sorry to bother you，I have a question .</p>
<p>(1) when I set like you did in <a href="https://github.com/pytorch/pytorch/blob/master/.jenkins/pytorch/win-test-helpers/build_pytorch.bat" rel="noopener nofollow ugc">build_pytorch.bat</a>:(about .exe file I download in “E:\build_torch\needed"; )</p>
<pre><code> echo @“E:\build_torch\needed\bin\randomtemp.exe” 

 E:\build_torch\needed\bin\sccache.exe” “%CUDA_PATH%\bin\nvcc.exe” %%* &gt; “%TMP_DIR%\bin\nvcc.bat”

 cat %TMP_DIR%\bin\nvcc.bat

 set CUDA_NVCC_EXECUTABLE=%TMP_DIR%\bin\nvcc.bat"
</code></pre>
<p>(2) Beginning, CUDA error in  build process, FindCUDA.camke line 790 “execute_process(COMMAN ${CUDA_NVCC_EXECUTABLE}) “–VERSION” ” ,<br>
It returned that “Failed to execute ‘E:/build_torch/tmp/bin/nvcc.bat --version’”, as:</p>
<p><strong>CMake Warning at cmake/Modules_CUDA_fix/upstream/FindCUDA.cmake:790 (message):</strong></p>
<p>**  Failed to execute ‘E:/build_torch/tmp/bin/nvcc.bat --version’**<br>
<strong>Call Stack (most recent call first):</strong></p>
<p>**  cmake/Modules_CUDA_fix/FindCUDA.cmake:11 (include)**</p>
<hr>
<p><strong>cmake/public/cuda.cmake:29 (find_package)</strong></p>
<hr>
<p><strong>cmake/Dependencies.cmake:1148 (include)</strong></p>
<hr>
<p><strong>CMakeLists.txt:564 (include)</strong></p>
<p>(3) Thus, cuda cannot be found.</p>
<pre><code>what's wrong with this set env var? Could you please help me
</code></pre>

Andy: <p>have you successed on windows?</p>