ERROR LNK2019 unresolved external symbol ""float __cdecl pow(float,int)" in function ""void __cdecl test_atomic_mul<float>(void)"

PlsHelp: <p>Hi everyone!</p>
<p>I have been trying to install Pytorch for over a week now, and I can not get it to work. After approximately 8 hours, the build always stops with:</p>
<pre><code class="lang-auto">Making of project "C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\caffe2\xla_tensor_test.vcxproj" is finished (Standardziele).

Making of project "C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\ALL_BUILD.vcxproj" is finished (Standardziele) -- ERROR.

Making of project "C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\install.vcxproj" is finished (Standardziele) -- ERROR.

Error in build process.
</code></pre>
<p>Then I get a bunch of similar warnings like:</p>
<pre><code class="lang-auto">"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\install.vcxproj" (Standardziel) (1) -&gt;
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\ALL_BUILD.vcxproj" (Standardziel) (3) -&gt;
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\caffe2\proto\Caffe2_PROTO.vcxproj" (Standardziel) (4) -&gt;
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\third_party\protobuf\cmake\protoc.vcxproj" (Standardziel) (5) -&gt;
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\third_party\protobuf\cmake\libprotobuf.vcxproj" (Standardziel) (6) -&gt;
(ClCompile Ziel) -&gt;
cl : Command line warning D9025 : overriding “/W1” with “/w” [C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\third_party\protobuf\cmake\libprotobuf.vcxproj]
</code></pre>
<p>And finally:</p>
<pre><code class="lang-auto">"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\install.vcxproj" (Standardziel) (1) -&gt;
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\ALL_BUILD.vcxproj" (Standardziel) (3) -&gt;
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\caffe2\cuda_atomic_ops_test.vcxproj" (Standardziel) (132) -&gt;
(Link Ziel) -&gt;
  cuda_atomic_ops_test_generated_cuda_atomic_ops_test.cu.obj : error LNK2019: unresolved external symbol ""float __cdecl pow(float,int)" (?pow@@YAMMH@Z)" in function ""void __cdecl test_atomic_mul&lt;float&gt;(void)" (?
?$test_atomic_mul@M@@YAXXZ)". [C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\caffe2\cuda_atomic_ops_test.vcxp
roj]
  cuda_atomic_ops_test_generated_cuda_atomic_ops_test.cu.obj : error LNK2019: unresolved external symbol ""double __cdecl pow(double,int)" (?pow@@YANNH@Z)" in function ""void __cdecl test_atomic_mul&lt;double&gt;(void)"
 (??$test_atomic_mul@N@@YAXXZ)". [C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\caffe2\cuda_atomic_ops_test.v
cxproj]
  C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\bin\Release\cuda_atomic_ops_test.exe : fatal error LNK1120: 2
 unresolved externals [C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\caffe2\cuda_atomic_ops_test.vcxproj]

    473 Warnings
    3 Errors

Passed Time 08:08:32.28
Traceback (most recent call last):
  File "C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\setup.py", line 717, in &lt;module&gt;
    build_deps()
    File "C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\setup.py", line 308, in build_deps
    build_caffe2(version=version,
  File "C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\tools\build_pytorch_libs.py", line 62, in build_caffe2
    cmake.build(my_env)
  File "C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\tools\setup_helpers\cmake.py", line 345, in build
    self.run(build_args, my_env)
  File "C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\tools\setup_helpers\cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "C:\Users\gooog\anaconda3\envs\torchbuild\lib\subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '/p:CL_MPCount=1']' returned non-zero exit status 1.
</code></pre>
<p>I translated some german parts, so don’t be confused if something sounds off. I did not know, how <code>(Standartziel)</code> is called in english, but it basically means “default target”. I hope, everything else is understandable.<br>
Some general information on my setup:</p>
<ul>
<li>Windows 10 (64 bit)</li>
<li>GPU: Nvidia GeForce 920M (Computing Capability = 3.5)</li>
<li>Driver Version: 426.00 (latest)</li>
<li>Visual Studio 2019 16.9.4 (Community)</li>
<li>CUDA 10.1.243</li>
<li>CuDNN 8.0.5</li>
</ul>
<p>This is how I install:</p>
<pre><code class="lang-auto">cd C:\Users\gooog\Downloads
mkdir Pytorch
cd Pytorch
conda create --name torchbuild
y
conda activate torchbuild
conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses
y
conda install -c conda-forge libuv=1.39
y
git clone --branch v1.7.0 https://github.com/pytorch/pytorch.git pytorch-1.7.0
cd pytorch-1.7.0
git clean -xdfcond
python setup.py clean
git submodule deinit -f --all
git submodule sync --recursive
git submodule update --init --recursive
</code></pre>
<p>At this point, I manually change two things in the source code in order to fix some bugs I encountered earlier:</p>
<ol>
<li>
<p>Adding <code>const</code> to C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\aten\src\ATen\native\CompositeRandomAccessorCommon.h according to:<br>
<a href="https://developercommunity.visualstudio.com/t/vs-1680-clexe-regression-causing-pytorch-build-fai/1255147" class="inline-onebox" rel="noopener nofollow ugc">Visual Studio Feedback</a></p>
</li>
<li>
<p>Adding a few lines to C:\Users\gooog\Downloads\Pytorch<br>
\pytorch-1.7.0\cmake\public\cuda.cmake according to:<br>
<a href="https://github.com/pytorch/pytorch/pull/54391/files" class="inline-onebox" rel="noopener nofollow ugc">[test] alternative fix for vc 16.8 with nvcc by peterjc123 · Pull Request #54391 · pytorch/pytorch · GitHub</a></p>
</li>
</ol>
<p>Then I continue installing:</p>
<pre><code class="lang-auto">set TMP_DIR_WIN=C:\Users\gooog\Downloads
C:/Users/gooog/Downloads/Use_mkl.bat
C:/Users/gooog/Downloads/Use_sccache.bat
set USE_NINJA=OFF
set CMAKE_VERBOSE_MAKEFILE=1
set CMAKE_GENERATOR=Visual Studio 16 2019
set CMAKE_GENERATOR_TOOLSET_VERSION=14.28
set DISTUTILS_USE_SDK=1
set PATH=%TMP_DIR_WIN%\bin;%PATH%
sccache --stop-server
sccache --start-server
sccache --zero-stats
set CC=sccache-cl
set CXX=sccache-cl
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=%CMAKE_GENERATOR_TOOLSET_VERSION%
set CUDAHOSTCXX=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe
set MAX_JOBS=1
python setup.py build --cmake
python setup.py install
</code></pre>
<p>Use_mkl.bat and Use_sccache.bat were copied from <a href="https://github.com/pytorch/pytorch/tree/master/.jenkins/pytorch/win-test-helpers/installation-helpers" class="inline-onebox" rel="noopener nofollow ugc">pytorch/.jenkins/pytorch/win-test-helpers/installation-helpers at master · pytorch/pytorch · GitHub</a></p>
<p>Since the files were rather long, I uploaded:</p>
<ul>
<li>CMakeError.log: <a href="https://justpaste.it/8b5vb" class="inline-onebox" rel="noopener nofollow ugc">CMakeError.log - JustPaste.it</a>
</li>
<li>CMakeOutput.log: <a href="https://justpaste.it/3xobh" class="inline-onebox" rel="noopener nofollow ugc">CMakeOutput.log - JustPaste.it</a>
</li>
</ul>
<p>This is the first time I try to install something from source, so please excuse some (probably) strange steps, like manually changing the source files <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"> .<br>
I need pytorch for my thesis, so any help would be very very much appreciated. Also let me know, if you need anything else.<br>
Many thanks in advance!</p>

ptrblck: <p>Based on the provided log it seems the error is:</p>
<pre><code class="lang-auto">`unresolved external symbol ""float __cdecl pow(float,int)"`
</code></pre>
<p>which points towards <a href="https://github.com/pytorch/pytorch/issues/48870">this older issue</a>, which should have been already solved in newer PyTorch versions.<br>
In case you need to use PyTorch <code>1.7.0</code> you could apply the proposed fixes mentioned in the issue or you could alternatively just update to the latest stable or nightly release.</p>

PlsHelp: <p>Thanks for the reply!<br>
Since my GPU is only compatible with CUDA 10.1, I think I am restricted to Pytorch v1.7.0 according to this table: <a href="https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md#building-on-legacy-code-and-cuda" class="inline-onebox" rel="noopener nofollow ugc">pytorch/CONTRIBUTING.md at master · pytorch/pytorch · GitHub</a><br>
I did not fully understand, how exactly CUDA and Pytorch versions depend on each other, so if you think that a newer version might also work, please let me know.<br>
Unfortunately, I was not able to find the older issue (were the square brackets supposed to be a link?).<br>
I found a bunch of other link errors, but none of them seemed to fit my problem.<br>
Could you maybe provide a link to the issue you meant?</p>

ptrblck: <aside class="quote no-group" data-username="PlsHelp" data-post="3" data-topic="121318">
<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/plshelp/48/38319_2.png" class="avatar"> PlsHelp:</div>
<blockquote>
<p>Since my GPU is only compatible with CUDA 10.1</p>
</blockquote>
</aside>
<p>I’m not sure why this would be the case.<br>
CUDA10.0 - CUDA11.3 all support GPUs with compute capability 3.5, so you could use all these CUDA toolkits.</p>
<aside class="quote no-group" data-username="PlsHelp" data-post="3" data-topic="121318">
<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/plshelp/48/38319_2.png" class="avatar"> PlsHelp:</div>
<blockquote>
<p>I did not fully understand, how exactly CUDA and Pytorch versions depend on each other, so if you think that a newer version might also work, please let me know.</p>
</blockquote>
</aside>
<p>Sorry for the wrong link, as apparently I didn’t post the right URL. Will edit the previous post and add the right link <a href="https://github.com/pytorch/pytorch/issues/48870">here</a> as well.</p>

PlsHelp: <p>Thanks again for the help.</p>
<aside class="quote no-group" data-username="ptrblck" data-post="4" data-topic="121318">
<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/ptrblck/48/1823_2.png" class="avatar"> ptrblck:</div>
<blockquote>
<p>I’m not sure why this would be the case.</p>
</blockquote>
</aside>
<p>As far as I understood, CUDA v10.2 and higher require a graphics driver version &gt;= 441.22, as mentioned in the second table <a href="https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html" rel="noopener nofollow ugc">here</a>, but the newest version I could find for my GPU is 426 (nvidia offers 425.31 <a href="https://www.nvidia.com/Download/driverResults.aspx/145874/en-us" rel="noopener nofollow ugc">here</a>, but somehow CUDA 10.1 included version 426.00).</p>
<p>Once again, if this has to be seen as a recommendation more than a hard requirement, or if there is another way of getting newer driver versions,  please let me know <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"> .</p>
<aside class="quote no-group" data-username="ptrblck" data-post="4" data-topic="121318">
<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/ptrblck/48/1823_2.png" class="avatar"> ptrblck:</div>
<blockquote>
<p>right link <a href="https://github.com/pytorch/pytorch/issues/48870" rel="noopener nofollow ugc">here</a> as well.</p>
</blockquote>
</aside>
<p>I added a third manual fix according to <a href="https://github.com/pytorch/pytorch/pull/48886/files" rel="noopener nofollow ugc">this</a> solution mentioned in your link and will now try again.<br>
Thanks again for your help, I will let you know if it worked.</p>

PlsHelp: <p>I think the fix worked so far, as the build goes further than before. Unfortunately, I encountered another error for which I could not find a fix:</p>
<pre><code class="lang-auto">Copying extension caffe2.python.caffe2_pybind11_state_gpu
Copying caffe2.python.caffe2_pybind11_state_gpu from torch\Lib\site-packages\caffe2\python\caffe2_pybind11_state_gpu.cp39-win_amd64.pyd to C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\lib.win-amd64-3.9\caffe2\python\caffe2_pybind11_state_gpu.cp39-win_amd64.pyd
copying torch\Lib\site-packages\caffe2\python\caffe2_pybind11_state_gpu.cp39-win_amd64.pyd -&gt; C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\lib.win-amd64-3.9\caffe2\python
building 'torch._C' extension
creating build\temp.win-amd64-3.9
creating build\temp.win-amd64-3.9\Release
creating build\temp.win-amd64-3.9\Release\torch
creating build\temp.win-amd64-3.9\Release\torch\csrc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\gooog\anaconda3\envs\torchbase\include -IC:\Users\gooog\anaconda3\envs\torchbase\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /Tctorch/csrc/stub.c /Fobuild\temp.win-amd64-3.9\Release\torch/csrc/stub.obj /MD /EHsc /DNOMINMAX /wd4267 /wd4251 /wd4522 /wd4522 /wd4838 /wd4305 /wd4244 /wd4190 /wd4101 /wd4996 /wd4275
stub.c
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\torch\lib /LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/lib/x64 /LIBPATH:C:\Users\gooog\anaconda3\envs\torchbase\libs /LIBPATH:C:\Users\gooog\anaconda3\envs\torchbase\PCbuild\amd64 /LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\ATLMFC\lib\x64 /LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\lib\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64 /LIBPATH:C:\Users\gooog\Downloads\mkl\lib torch_python.lib /EXPORT:PyInit__C build\temp.win-amd64-3.9\Release\torch/csrc/stub.obj /OUT:build\lib.win-amd64-3.9\torch\_C.cp39-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.9\Release\torch/csrc\_C.cp39-win_amd64.lib /NODEFAULTLIB:LIBCMT.LIB
LINK : fatal error LNK1181: Input file ".obj" cannot be opened.
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX64\\x64\\link.exe' failed with exit code 1181
</code></pre>
<p>I was not able to identify the relevant lines in the logs, so I send all 3:</p>
<ul>
<li><a href="https://justpaste.it/8geoy" rel="noopener nofollow ugc">Console Log</a></li>
<li><a href="https://justpaste.it/2evhm" rel="noopener nofollow ugc">CMakeOutput.log</a></li>
<li><a href="https://justpaste.it/703zk" rel="noopener nofollow ugc">CMakeError.log</a></li>
</ul>
<p>I would be really thankful if you could help me again, since I do not know what to try anymore.</p>

ptrblck: <p>I’m unfortunately not deeply familiar with laptop GPUs, so don’t know much about the driver support.</p>
<p>The current log error seems to be a bit vague in only mentioning that an “.obj” file cannot be opened. Note that the other two cmake files seem to be blocked.</p>

PlsHelp: <p>Thank your for the ongoing support.<br>
I corrected the links and the CMake files should be available now.</p>
<p>I think the (freely translated) relevant error message  is:</p>
<pre><code class="lang-auto">C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\CMakeFiles\CMakeTmp\src.cxx(1,10): fatal error C1083: cannot open file (Include): "glog/stl_logging.h": No such file or directory [C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\CMakeFiles\CMakeTmp\cmTC_e63a9.vcxproj]
</code></pre>
<p>Which lead to <a href="https://github.com/pytorch/pytorch/pull/16789/files" rel="noopener nofollow ugc">this</a> issue. I checked my CMakeLists.txt, but all these changes were already included. Any idea, what might be the problem?</p>

ptrblck: <p>Could you disable the <code>GLOG</code> usage via <code>USE_GLOG=0</code> in your env?<br>
Besides that it also seems that your current setup is missing <code>pthread.h</code>, <code>mpi.h</code>, <code>cpuid.h</code>, and <code>execinfo.h</code>.<br>
While these errors are raised as <code>fatal error</code>, I’m unsure if these would really break the build or skip the usage of some libs.</p>
<p>Did you make sure to use the recommended Visual Studio version as described <a href="https://github.com/pytorch/pytorch#from-source">here</a>?</p>

PlsHelp: <p>Thank you for the suggestion!</p>
<p>I reinstalled Visual Studio using <a href="https://github.com/pytorch/pytorch/blob/master/.circleci/scripts/vs_install.ps1" rel="noopener nofollow ugc">this</a> file (which installs BuildTools), and will set USE_GLOG=0, once it is done.<br>
While reinstalling CUDA, I now get the message that the installer can not find a supported version of Visual Studio, even though I located and added the following directories to my PATH:<br>
<code>C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\amd64 C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\bin\Hostx64\x64</code><br>
As far as I understood, CUDA wants a “real” Visual Studio version, e.g. Community, but the install instructions clearly suggest the BuildTools. Any idea on how to solve this?</p>
<p>Do you think it might help to install the missing files you mentioned? Where are they normally delivered?</p>

ptrblck: <p>I’m unfortunately not familiar with the Windows setup and don’t know which Visual Studio version etc. is needed, so we would have to wait for a Windows expert such as <a class="mention" href="/u/peterjc123">@peterjc123</a>.</p>

PlsHelp: <p>Okay, nonetheless thank you very much for your help so far.<br>
Hopefully <a class="mention" href="/u/peterjc123">@peterjc123</a> can help me resolve the last issues <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"> .</p>

peterjc123: <p>No no no, don’t add those paths to PATH systemwide. Actually, there should be a shortcut called x64 Native Tools Command Prompt for VS 2019 if you use “Windows Search”. Opening that window, all the VS related environmental variables will be properly set.</p>
<blockquote>
<p>As far as I understood, CUDA wants a “real” Visual Studio version, e.g. Community, but the install instructions clearly suggest the BuildTools. Any idea on how to solve this?</p>
</blockquote>
<p>It doesn’t care if you have build tools or community. Nvcc would be happy if you have MSVC toolchain installed.</p>
<p>As for your problem in building the library, it looks pretty similar to <a href="https://github.com/pytorch/pytorch/issues/47460" rel="noopener nofollow ugc">Cannot build PyTorch with Python 3.9 on Windows · Issue #47460 · pytorch/pytorch (github.com)</a> and is resolved by <a href="https://github.com/pytorch/pytorch/pull/47602" rel="noopener nofollow ugc">Fix python 3.9 builds on Windows by peterjc123 · Pull Request #47602 · pytorch/pytorch (github.com)</a>.</p>

PlsHelp: <p>Thanks for helping out.</p>
<p>I deleted the two lines from my PATH, and will use the VS command prompt you suggested. Does that mean, I should remove the following commands from my installation routine?</p>
<pre><code class="lang-auto">
set CMAKE_GENERATOR=Visual Studio 16 2019

set CMAKE_GENERATOR_TOOLSET_VERSION=14.28

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=%CMAKE_GENERATOR_TOOLSET_VERSION%

set CUDAHOSTCXX=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe
</code></pre>
<p>Another question:<br>
The issue that CUDA cannot find Visual Studio remains, even though I have</p>
<blockquote>
<p>MSVC v142 - VS 2019 C++-x64/x86-Buildtools (v14.28)</p>
</blockquote>
<p>installed (I installed Visual Studio and all components using <a href="https://github.com/pytorch/pytorch/blob/master/.circleci/scripts/vs_install.ps1" rel="noopener nofollow ugc">this previously mentioned file</a>)<br>
Should I just reinstall it using VS Community (which seemed to work), and install the newest MSVC and SDK?<br>
And if so, would you suggest VS Community 16.8.5 - matching the current Buildtools version - or the latest?</p>

peterjc123: <aside class="quote no-group" data-username="PlsHelp" data-post="14" data-topic="121318">
<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/plshelp/48/38319_2.png" class="avatar"> PlsHelp:</div>
<blockquote>
<p>I deleted the two lines from my PATH, and will use the VS command prompt you suggested. Does that mean, I should remove the following commands from my installation routine?</p>
</blockquote>
</aside>
<p>If you want to build with the VS generator, then you should probably set <code>CMAKE_GENERATOR</code>, otherwise, the Ninja generator will be used and you don’t need to set any one of them.</p>
<p>[quote=“PlsHelp, post:14, topic:121318”]<br>
The issue that CUDA cannot find Visual Studio remains, even though I have</p>
<blockquote>
<p>MSVC v142 - VS 2019 C+±x64/x86-Buildtools (v14.28)</p>
<p>installed (I installed Visual Studio and all components using <a href="https://github.com/pytorch/pytorch/blob/master/.circleci/scripts/vs_install.ps1" rel="noopener nofollow ugc">this previously mentioned file</a>)<br>
Should I just reinstall it using VS Community (which seemed to work), and install the newest MSVC and SDK?</p>
</blockquote>
<p>If it could work, then maybe you could just reinstall that. Actually, I don’t know too much about your local environment.</p>
<blockquote>
<p>And if so, would you suggest VS Community 16.8.5 - matching the current Buildtools version - or the latest?</p>
</blockquote>
<p>I see that you are using my patch. So it won’t have any problem using the latest one.</p>

PlsHelp: <aside class="quote no-group" data-username="peterjc123" data-post="15" data-topic="121318">
<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/peterjc123/48/2790_2.png" class="avatar"> peterjc123:</div>
<blockquote>
<p>If you want to build with the VS generator, then you should probably set <code>CMAKE_GENERATOR</code>, otherwise, the Ninja generator will be used and you don’t need to set any one of them.</p>
</blockquote>
</aside>
<p>I do not remember exactly what happened, but I build with the VS generator, since Ninja had some issues for me.</p>
<p>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:</p>
<pre><code class="lang-auto">
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 &lt;stdint.h&gt;
      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(&amp;a, &amp;b, &amp;c, &amp;d);
        return 0;
      }
</code></pre>
<p>Based on the command prompt output, the problem seems to be related to gloo:</p>
<pre><code class="lang-auto">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) -&gt;
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\ALL_BUILD.vcxproj" (Standardziel) (3) -&gt;
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\caffe2\caffe2_pybind11_state.vcxproj" (Standardziel) (18) -&gt;
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\caffe2\torch.vcxproj" (Standardziel) (26) -&gt;
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\caffe2\torch_cuda.vcxproj" (Standardziel) (37) -&gt;
"C:\Users\gooog\Downloads\Pytorch\pytorch-1.7.0\build\third_party\gloo\gloo\gloo_cuda.vcxproj" (Standardziel) (39) -
&gt;
(CustomBuild Ziel) -&gt;
  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]
</code></pre>
<p>I do not understand what gloo does, but could it help to just <code>set USE_GLOO=0</code>, and would this in any way affect the build?</p>
<p>On another note, I am still missing the following files (as ptrblck already pointed out):</p>
<ul>
<li>glog/stl_logging.h</li>
<li>pthread.h</li>
<li>mpi.h</li>
<li>cpuid.h</li>
<li>execinfo.h</li>
</ul>
<p>Would you confirm that this is not problematic for the build / later use?</p>

PlsHelp: <p>Conserning the first issue, I tried to build again with <code>USE_GLOO=0</code>, but I am hitting the same error. Based on <a href="https://stackoverflow.com/questions/35131350/error-asm-undeclared-first-use-in-this-function" rel="noopener nofollow ugc">this somewhat smiliar issue</a>, I think it should say <code>__asm__</code> insted of <code>asm</code> in <code>\build\CMakeFiles\CMakeTmp\src.c</code>, but since this is a temporary file, that is generated only during the build, I do not know how to fix this. Any idea on what to do <a class="mention" href="/u/peterjc123">@peterjc123</a> ?</p>

peterjc123: <p>Could you please share me the full log? BTW, would you please share the log if you use the Ninja generator?</p>

PlsHelp: <p>These are the logs of the last run (with <code>USE_GLOO=0</code>)</p>
<ul>
<li><a href="https://justpaste.it/5q0ao" rel="noopener nofollow ugc">CMakeError.log</a></li>
<li><a href="https://justpaste.it/5gw5d" rel="noopener nofollow ugc">CMakeOutput.log</a></li>
</ul>
<p>I will now try to build with Ninja again and send you the logs once it is done. In order to do so, I just <code>set USE_NINJA=ON</code> and remove the following lines from my installation routine, right?</p>
<pre><code class="lang-auto">set CMAKE_VERBOSE_MAKEFILE=1
set CMAKE_GENERATOR=Visual Studio 16 2019
set CMAKE_GENERATOR_TOOLSET_VERSION=14.29
set DISTUTILS_USE_SDK=1
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=%CMAKE_GENERATOR_TOOLSET_VERSION%
set CUDAHOSTCXX=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX64\x64\cl.exe
</code></pre>
<p>So my new installation routine will be the following:</p>
<pre><code class="lang-auto">
set TMP_DIR_WIN=C:\Users\gooog\Downloads
C:/Users/gooog/Downloads/Use_mkl.bat
C:/Users/gooog/Downloads/Use_sccache.bat

set USE_NINJA=ON
set PATH=%TMP_DIR_WIN%\bin;%PATH%
sccache --stop-server
sccache --start-server
sccache --zero-stats
set CC=sccache-cl
set CXX=sccache-cl
set MAX_JOBS=1
set USE_GLOG=0
set USE_GLOO=0
python setup.py build --cmake
python setup.py install
</code></pre>
<p>Thanks a lot for your help!</p>

peterjc123: <aside class="quote no-group" data-username="PlsHelp" data-post="19" data-topic="121318">
<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/plshelp/48/38319_2.png" class="avatar"> PlsHelp:</div>
<blockquote>
<p>These are the logs of the last run (with <code>USE_GLOO=0</code>)</p>
<ul>
<li><a href="https://justpaste.it/5q0ao" rel="noopener nofollow ugc">CMakeError.log </a></li>
<li><a href="https://justpaste.it/5gw5d" rel="noopener nofollow ugc">CMakeOutput.log </a></li>
</ul>
</blockquote>
</aside>
<p>The logs you provided are not informative. By “full log”, I mean you redirect stdout and stderr to a log file (by appending <code>&gt; build.log 2&gt;&amp;1</code> after every command or just write all the commands into a script and run that script with this pattern) and please upload that log file.</p>
<blockquote>
<p>I will now try to build with Ninja again and send you the logs once it is done. In order to do so, I just <code>set USE_NINJA=ON</code> and remove the following lines from my installation routine, right?</p>
</blockquote>
<p>You still need this if you use a regular CMD window instead of opening a x64 MSVC dev shell.<br>
<code>"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=%CMAKE_GENERATOR_TOOLSET_VERSION%</code></p>
<p>BTW, <code>set DISTUTILS_USE_SDK=1</code> is still needed.</p>