<h2 dir="auto">🐛 Bug</h2>

<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Steps to reproduce the behavior:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[root@ip-172-26-11-98 ~]# python3.9 -m pip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Looking in links: https://download.pytorch.org/whl/torch_stable.html
ERROR: Could not find a version that satisfies the requirement torch==1.7.0+cpu (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch==1.7.0+cpu"><pre class="notranslate"><code class="notranslate">[root@ip-172-26-11-98 ~]# python3.9 -m pip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Looking in links: https://download.pytorch.org/whl/torch_stable.html
ERROR: Could not find a version that satisfies the requirement torch==1.7.0+cpu (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch==1.7.0+cpu
</code></pre></div>

<h2 dir="auto">Expected behavior</h2>

<p dir="auto">Successful installation of torch</p>
<h2 dir="auto">Environment</h2>
<ul dir="auto">
<li>PyTorch Version (e.g., 1.0): 1.7</li>
<li>OS (e.g., Linux): CentOS 7.8</li>
<li>How you installed PyTorch (<code class="notranslate">conda</code>, <code class="notranslate">pip</code>, source): pip</li>
<li>Build command you used (if compiling from source):</li>
<li>Python version: 3.9</li>
<li>CUDA/cuDNN version:</li>
<li>GPU models and configuration:</li>
<li>Any other relevant information: I had built Python3.9 from source.</li>
</ul>
<h2 dir="auto">Additional context</h2>
<p dir="auto">I had built Python 3.9 this way:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="yum install openssl-devel readline-devel libuuid-devel gdbm-devel sqlite-devel bzip bzip2-devel libffi-devel
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
tar -xzf Python-3.9.0.tgz
rm -rf Python-3.9.0.tgz
cd Python-3.9.0
mkdir build
cd build
../configure --sbindir=/usr/bin/python3.9
make
make install"><pre class="notranslate"><code class="notranslate">yum install openssl-devel readline-devel libuuid-devel gdbm-devel sqlite-devel bzip bzip2-devel libffi-devel
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
tar -xzf Python-3.9.0.tgz
rm -rf Python-3.9.0.tgz
cd Python-3.9.0
mkdir build
cd build
../configure --sbindir=/usr/bin/python3.9
make
make install
</code></pre></div>
<h2 dir="auto">🐛 Windows LibTorch C++ Cannot Load CUDA Module</h2>
<p dir="auto"><code class="notranslate">th.jit.trace()</code>'ing or <code class="notranslate">th.jit.script()</code>'ing even just a Conv2d module will produce a serialized file that cannot be loaded by the C++ runtime. See the following two example scripts for a repro:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import torch as th
from torch import nn

d = th.nn.Conv2d(3, 3, 1, 1, 0).cuda()
z = th.zeros(1, 3, 256, 256).cuda()
th.jit.script(d).save(&quot;smod.ptj&quot;) # Also fails if this is th.jit.trace(d, (z,))"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">torch</span> <span class="pl-k">as</span> <span class="pl-s1">th</span>
<span class="pl-k">from</span> <span class="pl-s1">torch</span> <span class="pl-k">import</span> <span class="pl-s1">nn</span>

<span class="pl-s1">d</span> <span class="pl-c1">=</span> <span class="pl-s1">th</span>.<span class="pl-s1">nn</span>.<span class="pl-v">Conv2d</span>(<span class="pl-c1">3</span>, <span class="pl-c1">3</span>, <span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">0</span>).<span class="pl-en">cuda</span>()
<span class="pl-s1">z</span> <span class="pl-c1">=</span> <span class="pl-s1">th</span>.<span class="pl-en">zeros</span>(<span class="pl-c1">1</span>, <span class="pl-c1">3</span>, <span class="pl-c1">256</span>, <span class="pl-c1">256</span>).<span class="pl-en">cuda</span>()
<span class="pl-s1">th</span>.<span class="pl-s1">jit</span>.<span class="pl-en">script</span>(<span class="pl-s1">d</span>).<span class="pl-en">save</span>(<span class="pl-s">"smod.ptj"</span>) <span class="pl-c"># Also fails if this is th.jit.trace(d, (z,))</span></pre></div>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#include &lt;iostream&gt;
#include &lt;torch/script.h&gt;
int main() {
    try {
        auto mod = torch::jit::load(&quot;smod.ptj&quot;);
    } catch(c10::Error&amp; e) {
        std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;
        return 1;
    }
    return 0;
}"><pre class="notranslate">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>iostream<span class="pl-pds">&gt;</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>torch/script.h<span class="pl-pds">&gt;</span></span>
<span class="pl-k">int</span> <span class="pl-en">main</span>() {
    <span class="pl-k">try</span> {
        <span class="pl-k">auto</span> mod = <span class="pl-c1">torch::jit::load</span>(<span class="pl-s"><span class="pl-pds">"</span>smod.ptj<span class="pl-pds">"</span></span>);
    } <span class="pl-k">catch</span>(c10::Error&amp; e) {
        std::cerr &lt;&lt; e.<span class="pl-c1">what</span>() &lt;&lt; std::endl;
        <span class="pl-k">return</span> <span class="pl-c1">1</span>;
    }
    <span class="pl-k">return</span> <span class="pl-c1">0</span>;
}</pre></div>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Steps to reproduce the behavior:</p>
<ol dir="auto">
<li>Run the above python script.</li>
<li>Compile + run the above C++ program.</li>
</ol>
<p dir="auto">The exception text is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cuda_dispatch_ptr INTERNAL ASSERT FAILED at C:\w\1\s\windows\pytorch\aten\src\ATen/native/DispatchStub.h:70, please report a bug to PyTorch. DispatchStub: missing CUDA kernel (operator () at C:\w\1\s\windows\pytorch\aten\src\ATen/native/DispatchStub.h:70)
(no backtrace available)"><pre class="notranslate"><code class="notranslate">cuda_dispatch_ptr INTERNAL ASSERT FAILED at C:\w\1\s\windows\pytorch\aten\src\ATen/native/DispatchStub.h:70, please report a bug to PyTorch. DispatchStub: missing CUDA kernel (operator () at C:\w\1\s\windows\pytorch\aten\src\ATen/native/DispatchStub.h:70)
(no backtrace available)
</code></pre></div>
<p dir="auto">and is thrown at <code class="notranslate">include\ATen\core\TensorMethods.h:249</code> (the end of an inline <code class="notranslate">copy_</code> method).</p>
<p dir="auto">Problem persists with latest master builds as well.</p>
<p dir="auto">I used linux to dump the module since installing pytorch from anaconda currently results in a pytorch that will not import:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    from torch._C import *
ImportError: DLL load failed: The specified procedure could not be found."><pre class="notranslate"><code class="notranslate">    from torch._C import *
ImportError: DLL load failed: The specified procedure could not be found.
</code></pre></div>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">C++ program returns 0 w/no errors displayed.</p>
<h2 dir="auto">Environment</h2>
<ul dir="auto">
<li>PyTorch Version (e.g., 1.0): 1.2 stable (also nightly)</li>
<li>OS (e.g., Linux): Windows</li>
<li>How you installed PyTorch (<code class="notranslate">conda</code>, <code class="notranslate">pip</code>, source): conda (linux), pytorch.org (win binaries)</li>
<li>Build command you used (if compiling from source):</li>
<li>Python version: 3.7</li>
<li>CUDA/cuDNN version: 10.0 / 3.6</li>
<li>GPU models and configuration: Titan RTX</li>
</ul>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/peterjc123/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/peterjc123">@peterjc123</a></p>