Error with cpp_extentions

G.M: <p>I encountered this problem first.</p>
<pre><code class="lang-auto">&gt;&gt;&gt; from setuptools import setup, Extension
&gt;&gt;&gt; from torch.utils import cpp_extension
INFO: Could not find files for the given pattern(s).
</code></pre>
<p>And when I’m trying to use code <a href="https://pytorch.org/tutorials/advanced/cpp_extension.html" rel="nofollow noopener">here</a> to compile a simple extension, I encountered this issue, which I suspect is related to the problem above. But I’m not sure what is it exactly.</p>
<pre><code class="lang-auto">UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified
</code></pre>
<p>I googled this issue but didn’t find a satisfactory answer.</p>

LeviViana: <p>Seems related to <a href="https://github.com/pytorch/pytorch/issues/9263" rel="nofollow noopener">this issue</a>. And apparently the solution was <a href="https://github.com/pytorch/pytorch/issues/9263#issuecomment-474194579" rel="nofollow noopener">to upgrade python</a>.</p>

G.M: <p>Thanks 4 ur reply.<br>
I’m using Python 3.7.3 with Pytorch 1.1.0 on windows 10, which version of Python should I use with torch 1.1.0?</p>

peterjc123: <p>The reason is that it needs to find the compiler for the cpp_extension, which is called <code>cl</code>. You should have VS 2017 installed, start “x64 Native Tools Command Prompt for VS 2017” and run <code>python</code> in that environment.</p>

G.M: <p>Thanks for replying!<br>
Sadly I’m still getting that “INFO” thing even though I ran it in the cmd prompt u mentioned.</p>

peterjc123: <p>The corresponding code: <a href="https://github.com/pytorch/pytorch/blob/master/torch/utils/cpp_extension.py#L24-L50" rel="nofollow noopener">https://github.com/pytorch/pytorch/blob/master/torch/utils/cpp_extension.py#L24-L50</a>. Looks like we didn’t suppress the output of <code>where nvcc</code>. Fix: <a href="https://github.com/pytorch/pytorch/pull/32620" rel="nofollow noopener">https://github.com/pytorch/pytorch/pull/32620</a>.</p>

G.M: <p>Judging from the code, this warning will display if I don’t have CUDA, correct?</p>

peterjc123: <p>Yes. It will display the warning message if the command <code>where nvcc</code> fails. It may be a result of missing CUDA installation.</p>

G.M: <p>Thx. That explains. I’m using cpu version on my pc, because I don’t have cuda installed.</p>

Victory: <p>I do have cuda installed. I also have Visual Studio 2019 installed. But, I still get the following error. Any idea why?</p>
<p>C:\Users\myusername\AppData\Local\Continuum\anaconda3\envs\myenvname\lib\site-packages\torch\utils\cpp_extension.py:238: UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified<br>
warnings.warn(‘Error checking compiler version for {}: {}’.format(compiler, error))</p>

Tehreem: <p>Hi,<br>
I also got this error:</p>
<p>UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified.</p>
<p>How to fix this issue?</p>
<p>Please help.</p>
<p>Thanks</p>

loveunk: <p>Thanks, it works for me!</p>

JamesDickens: <p>Did you fix this? I am having the same issue.</p>

Ziyu_Huang: <p>But in that prompt I can not use my conda environment…And thus no torch library…Any suggestion?</p>