Windows PyTorch extension compilation issues

username: stefdoerr
cooked: <p>Hi, I am trying to compile a torch extension on Windows <a href="https://github.com/openmm/NNPOps/" class="inline-onebox" rel="noopener nofollow ugc">GitHub - openmm/NNPOps: High-performance operations for neural network potentials</a><br>
but I am getting errors: <code>error C2872: 'std': ambiguous symbol</code></p>
<aside class="onebox githubblob" data-onebox-src="https://github.com/openmm/NNPOps/blob/master/src/pytorch/neighbors/getNeighborPairsCUDA.cu#L1-L5">
  <header class="source">

      <a href="https://github.com/openmm/NNPOps/blob/master/src/pytorch/neighbors/getNeighborPairsCUDA.cu#L1-L5" target="_blank" rel="noopener nofollow ugc">github.com/openmm/NNPOps</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://github.com/openmm/NNPOps/blob/master/src/pytorch/neighbors/getNeighborPairsCUDA.cu#L1-L5" target="_blank" rel="noopener nofollow ugc">src/pytorch/neighbors/getNeighborPairsCUDA.cu</a></h4>

<div class="git-blob-info">
  <a href="https://github.com/openmm/NNPOps/blob/master/src/pytorch/neighbors/getNeighborPairsCUDA.cu#L1-L5" rel="noopener nofollow ugc"><code>master</code></a>
</div>



    <pre class="onebox"><code class="lang-cu">
      <ol class="start lines" start="1" style="counter-reset: li-counter 0 ;">
          <li>#include &lt;c10/cuda/CUDAGuard.h&gt;</li>
          <li>#include &lt;c10/cuda/CUDAStream.h&gt;</li>
          <li>#include &lt;exception&gt;</li>
          <li>#include &lt;stdexcept&gt;</li>
          <li>#include &lt;torch/extension.h&gt;</li>
      </ol>
    </code></pre>



  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<pre><code class="lang-auto">    getNeighborPairsCUDA.cu
    tmpxft_00000a04_00000000-7_getNeighborPairsCUDA.compute_90.cudafe1.cpp
    C:/Users/runneradmin/AppData/Local/Temp/pip-build-env-4ak9qebn/overlay/Lib/site-packages/torch/include\torch/csrc/dynamo/compiled_autograd.h(1347): error C2872: 'std': ambiguous symbol
    C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/include\valarray(21): note: could be 'std'
    C:/Users/runneradmin/AppData/Local/Temp/pip-build-env-4ak9qebn/overlay/Lib/site-packages/torch/include\torch/csrc/dynamo/compiled_autograd.h(1347): note: or       'std'
</code></pre>
<p>and <a href="https://github.com/openmm/NNPOps/blob/master/src/pytorch/pme/pmeCUDA.cu#L1-L3" class="inline-onebox" rel="noopener nofollow ugc">NNPOps/src/pytorch/pme/pmeCUDA.cu at master · openmm/NNPOps · GitHub</a></p>
<pre><code class="lang-auto">     pmeCUDA.cu
    tmpxft_00000db0_00000000-7_pmeCUDA.compute_90.cudafe1.cpp
    C:/Users/runneradmin/AppData/Local/Temp/pip-build-env-m_wzmh56/overlay/Lib/site-packages/torch/include\torch/csrc/dynamo/compiled_autograd.h(1347): error C2872: 'std': ambiguous symbol
    C:/Users/runneradmin/AppData/Local/Temp/pip-build-env-m_wzmh56/overlay/Lib/site-packages/torch/include\c10/cuda/CUDAStream.h(261): note: could be 'std'
    C:/Users/runneradmin/AppData/Local/Temp/pip-build-env-m_wzmh56/overlay/Lib/site-packages/torch/include\torch/csrc/dynamo/compiled_autograd.h(1347): note: or       'std'
</code></pre>
<p>It seems to me like the <code>std</code> definition of c10 here <a href="https://github.com/pytorch/pytorch/blob/main/c10/cuda/CUDAStream.h#L261-L268" class="inline-onebox" rel="noopener nofollow ugc">pytorch/c10/cuda/CUDAStream.h at main · pytorch/pytorch · GitHub</a> is causing collisions with:</p>
<ol>
<li>the std definition in the Microsoft headers and</li>
<li>the std definition in the torch dynamo headers</li>
</ol>
<p>This doesn’t seem to cause any issues on Linux surprisingly. Is there any way to fix these issues with the Windows builds?</p>