<h2 dir="auto"><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> Bug</h2>

<p dir="auto">Error text:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    [1054/2736] Building CXX object caffe2\CMakeFiles\torch_cpu.dir\__\aten\src\ATen\ExpandUtils.cpp.obj
    FAILED: caffe2/CMakeFiles/torch_cpu.dir/__/aten/src/ATen/ExpandUtils.cpp.obj
    C:\w\1\s\windows\tmp_bin\sccache.exe  cl  /nologo /TP -DAT_PARALLEL_OPENMP=1 -DCPUINFO_SUPPORTED_PLATFORM=1 -DMAGMA_V2 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DTH_BLAS_MKL -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE=1 -D_OPENMP_NOFORCE_MANIFEST -Dtorch_cpu_EXPORTS -Iaten\src -I..\aten\src -I. -I..\ -I..\cmake\..\third_party\benchmark\include -Icaffe2\contrib\aten -I..\third_party\onnx -Ithird_party\onnx -I..\third_party\foxi -Ithird_party\foxi -I..\caffe2\..\torch\csrc\api -I..\caffe2\..\torch\csrc\api\include -I..\caffe2\aten\src\TH -Icaffe2\aten\src\TH -I..\caffe2\..\torch\..\aten\src -Icaffe2\aten\src -Icaffe2\..\aten\src -Icaffe2\..\aten\src\ATen -I..\caffe2\..\torch\csrc -I..\caffe2\..\torch\..\third_party\miniz-2.0.8 -I..\aten\src\TH -I..\aten\..\third_party\catch\single_include -I..\aten\src\ATen\.. -Icaffe2\aten\src\ATen -I..\third_party\miniz-2.0.8 -I..\caffe2\core\nomnigraph\include -I..\c10\.. -I..\third_party\cpuinfo\include -I..\third_party\FP16\include -I..\cmake\..\third_party\googletest\googlemock\include -I..\cmake\..\third_party\googletest\googletest\include -I..\third_party\protobuf\src -IC:\w\1\s\windows\mkl\include -I..\cmake\..\third_party\eigen -IC:\w\1\s\windows\conda\envs\py37\include -IC:\w\1\s\windows\conda\envs\py37\lib\site-packages\numpy\core\include -I..\cmake\..\third_party\pybind11\include -I\opt\rocm\hip\include -I\include -I..\cmake\..\third_party\cub -IC:\w\1\s\windows\magma_cuda101_release\include -I&quot;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include&quot; -I..\caffe2 /DWIN32 /D_WINDOWS  /GR  /w /EHa /MP /bigobj -openmp -DHAVE_AVX_CPU_DEFINITION -DHAVE_AVX2_CPU_DEFINITION /MD /O2 /Ob2  /w /EHa /MP /bigobj   -DCUDA_HAS_FP16=1 -DUSE_GCC_GET_CPUID -DUSE_AVX -DUSE_AVX2 -DTH_HAVE_THREAD /Z7 /EHa /DNOMINMAX /wd4267 /wd4251 /wd4522 /wd4838 /wd4305 /wd4244 /wd4190 /wd4101 /wd4996 /wd4275 /bigobj -O2 -DCAFFE2_BUILD_MAIN_LIB -DONNX_BUILD_MAIN_LIB -std:c++14 /showIncludes /Focaffe2\CMakeFiles\torch_cpu.dir\__\aten\src\ATen\ExpandUtils.cpp.obj /Fdcaffe2\CMakeFiles\torch_cpu.dir\ /FS -c ..\aten\src\ATen\ExpandUtils.cpp
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(302): error C2061: syntax error: identifier 'IValue'
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(302): error C2238: unexpected token(s) preceding ';'
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(306): error C2988: unrecognizable template declaration/definition
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(306): error C2059: syntax error: 'return'
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(306): error C2653: 'Tag': is not a class or namespace name
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(306): error C2238: unexpected token(s) preceding ';'
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(307): error C2146: syntax error: missing ';' before identifier 'toGenericDict'
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(307): error C2270: 'toGenericDict': modifiers not allowed on nonmember functions
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(63): error C2653: 'Tag': is not a class or namespace name
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(63): error C2065: 'None': undeclared identifier
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(63): error C2614: 'c10::IValue': illegal member initialization: 'payload' is not a base or member
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(63): error C2614: 'c10::IValue': illegal member initialization: 'tag' is not a base or member
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(63): error C2614: 'c10::IValue': illegal member initialization: 'is_intrusive_ptr' is not a base or member
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(63): fatal error C1903: unable to recover from previous error(s); stopping compilation
    Internal Compiler Error in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\cl.exe.  You will be prompted to send an error report to Microsoft later.
    INTERNAL COMPILER ERROR in 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\cl.exe'
        Please choose the Technical Support command on the Visual C++
        Help menu, or open the Technical Support help file for more information"><pre class="notranslate"><code class="notranslate">    [1054/2736] Building CXX object caffe2\CMakeFiles\torch_cpu.dir\__\aten\src\ATen\ExpandUtils.cpp.obj
    FAILED: caffe2/CMakeFiles/torch_cpu.dir/__/aten/src/ATen/ExpandUtils.cpp.obj
    C:\w\1\s\windows\tmp_bin\sccache.exe  cl  /nologo /TP -DAT_PARALLEL_OPENMP=1 -DCPUINFO_SUPPORTED_PLATFORM=1 -DMAGMA_V2 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DTH_BLAS_MKL -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE=1 -D_OPENMP_NOFORCE_MANIFEST -Dtorch_cpu_EXPORTS -Iaten\src -I..\aten\src -I. -I..\ -I..\cmake\..\third_party\benchmark\include -Icaffe2\contrib\aten -I..\third_party\onnx -Ithird_party\onnx -I..\third_party\foxi -Ithird_party\foxi -I..\caffe2\..\torch\csrc\api -I..\caffe2\..\torch\csrc\api\include -I..\caffe2\aten\src\TH -Icaffe2\aten\src\TH -I..\caffe2\..\torch\..\aten\src -Icaffe2\aten\src -Icaffe2\..\aten\src -Icaffe2\..\aten\src\ATen -I..\caffe2\..\torch\csrc -I..\caffe2\..\torch\..\third_party\miniz-2.0.8 -I..\aten\src\TH -I..\aten\..\third_party\catch\single_include -I..\aten\src\ATen\.. -Icaffe2\aten\src\ATen -I..\third_party\miniz-2.0.8 -I..\caffe2\core\nomnigraph\include -I..\c10\.. -I..\third_party\cpuinfo\include -I..\third_party\FP16\include -I..\cmake\..\third_party\googletest\googlemock\include -I..\cmake\..\third_party\googletest\googletest\include -I..\third_party\protobuf\src -IC:\w\1\s\windows\mkl\include -I..\cmake\..\third_party\eigen -IC:\w\1\s\windows\conda\envs\py37\include -IC:\w\1\s\windows\conda\envs\py37\lib\site-packages\numpy\core\include -I..\cmake\..\third_party\pybind11\include -I\opt\rocm\hip\include -I\include -I..\cmake\..\third_party\cub -IC:\w\1\s\windows\magma_cuda101_release\include -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include" -I..\caffe2 /DWIN32 /D_WINDOWS  /GR  /w /EHa /MP /bigobj -openmp -DHAVE_AVX_CPU_DEFINITION -DHAVE_AVX2_CPU_DEFINITION /MD /O2 /Ob2  /w /EHa /MP /bigobj   -DCUDA_HAS_FP16=1 -DUSE_GCC_GET_CPUID -DUSE_AVX -DUSE_AVX2 -DTH_HAVE_THREAD /Z7 /EHa /DNOMINMAX /wd4267 /wd4251 /wd4522 /wd4838 /wd4305 /wd4244 /wd4190 /wd4101 /wd4996 /wd4275 /bigobj -O2 -DCAFFE2_BUILD_MAIN_LIB -DONNX_BUILD_MAIN_LIB -std:c++14 /showIncludes /Focaffe2\CMakeFiles\torch_cpu.dir\__\aten\src\ATen\ExpandUtils.cpp.obj /Fdcaffe2\CMakeFiles\torch_cpu.dir\ /FS -c ..\aten\src\ATen\ExpandUtils.cpp
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(302): error C2061: syntax error: identifier 'IValue'
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(302): error C2238: unexpected token(s) preceding ';'
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(306): error C2988: unrecognizable template declaration/definition
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(306): error C2059: syntax error: 'return'
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(306): error C2653: 'Tag': is not a class or namespace name
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(306): error C2238: unexpected token(s) preceding ';'
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(307): error C2146: syntax error: missing ';' before identifier 'toGenericDict'
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(307): error C2270: 'toGenericDict': modifiers not allowed on nonmember functions
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(63): error C2653: 'Tag': is not a class or namespace name
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(63): error C2065: 'None': undeclared identifier
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(63): error C2614: 'c10::IValue': illegal member initialization: 'payload' is not a base or member
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(63): error C2614: 'c10::IValue': illegal member initialization: 'tag' is not a base or member
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(63): error C2614: 'c10::IValue': illegal member initialization: 'is_intrusive_ptr' is not a base or member
    C:\w\1\s\windows\pytorch\aten\src\ATen/core/ivalue.h(63): fatal error C1903: unable to recover from previous error(s); stopping compilation
    Internal Compiler Error in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\cl.exe.  You will be prompted to send an error report to Microsoft later.
    INTERNAL COMPILER ERROR in 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\cl.exe'
        Please choose the Technical Support command on the Visual C++
        Help menu, or open the Technical Support help file for more information
</code></pre></div>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Steps to reproduce the behavior:</p>
<ol dir="auto">
<li>python setup.py install</li>
</ol>

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

<h2 dir="auto">Environment</h2>
<p dir="auto">Please copy and paste the output from our<br>
<a href="https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py" rel="nofollow">environment collection script</a><br>
(or fill out the checklist below manually).</p>
<p dir="auto">You can get the script and run it with:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py"><pre class="notranslate"><code class="notranslate">wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
</code></pre></div>
<ul dir="auto">
<li>PyTorch Version (e.g., 1.0): <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pytorch/pytorch/commit/3c8892aa0cd80e62f01b1ba3c99e4f5fd713868c/hovercard" href="https://github.com/pytorch/pytorch/commit/3c8892aa0cd80e62f01b1ba3c99e4f5fd713868c"><tt>3c8892a</tt></a></li>
<li>OS (e.g., Linux): Windows</li>
<li>How you installed PyTorch (<code class="notranslate">conda</code>, <code class="notranslate">pip</code>, source): source</li>
<li>Build command you used (if compiling from source): source</li>
<li>Python version: 3.5/3.6/3.7</li>
<li>CUDA/cuDNN version: Node / 9.2 / 10.1</li>
<li>GPU models and configuration: None</li>
<li>Any other relevant information:</li>
</ul>
<h2 dir="auto">Additional context</h2>

<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>
<h2 dir="auto"><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> Bug</h2>
<p dir="auto">When trying to compile with VS2019 but targeting v141 toolchain and cuda 10.0 there seems to be some issues with rewrite of dispatching that was done in recent weeks.</p>
<p dir="auto">This snippet was from building using facebook internal Buck, but I was able to reproduce same thing using cmake.</p>
<p dir="auto">Compiling with /permissive- fixed the "no matching overload" error, but raises some other cuda errors related to <code class="notranslate">__nv_hdl_create_wrapper_t</code></p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Steps to reproduce the behavior:</p>
<ol dir="auto">
<li>checkout pytorch master</li>
<li>pass v141 as toolchain to cmake when generating</li>
<li>set cuda sdk root to 10.0</li>
<li>try and build torch_cuda</li>
</ol>
<p dir="auto">Error without /permissive-</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="caffe2\aten\src\aten\core\boxing\KernelFunction_impl.h(67): error C2672: 'c10::impl::boxAndCallBoxedFunc': no matching overloaded function found
caffe2/aten/src\ATen/core/dispatch/Dispatcher.h(180): note: see reference to function template instantiation 'Return c10::KernelFunction::callUnboxed&lt;Return,const at::Tensor&amp;,const at::Tensor&amp;,bool,bool&gt;(const c10::OperatorHandle &amp;,const at::Tensor &amp;,const at::Tensor &amp;,bool,bool) const' being compiled
        with
        [
            Return=void
        ]
caffe2/aten/src\ATen/core/dispatch/Dispatcher.h(155): note: see reference to function template instantiation 'Return c10::Dispatcher::callUnboxed&lt;Return,const at::Tensor&amp;,const at::Tensor&amp;,bool,bool&gt;(const c10::OperatorHandle &amp;,const at::Tensor &amp;,const at::Tensor &amp;,bool,bool) const' being compiled
        with
        [
            Return=void
        ]
caffe2\ATen/core/TensorMethods.h(66): note: see reference to function template instantiation 'Return c10::OperatorHandle::callUnboxed&lt;void,const at::Tensor&amp;,const at::Tensor&amp;,bool,bool&gt;(const at::Tensor &amp;,const at::Tensor &amp;,bool,bool) const' being compiled
        with
        [
            Return=void
        ]
caffe2\aten\src\aten\core\boxing\KernelFunction_impl.h(67): error C2770: invalid explicit template argument(s) for 'Result c10::impl::boxAndCallBoxedFunc(c10::KernelFunction::InternalBoxedKernelFunction (__cdecl *),c10::OperatorKernel *,const c10::OperatorHandle &amp;,Args...,enable_if&lt;_Test,_Ty&gt;::type)'
        with
        [
            _Ty=int
        ]
caffe2/aten/src\ATen/core/boxing/boxing.h(53): note: see declaration of 'c10::impl::boxAndCallBoxedFunc'
caffe2\aten\src\aten\core\boxing\KernelFunction_impl.h(67): error C2893: Failed to specialize function template 'Result c10::impl::boxAndCallBoxedFunc(c10::KernelFunction::InternalBoxedKernelFunction (__cdecl *),c10::OperatorKernel *,const c10::OperatorHandle &amp;,Args...,enable_if&lt;_Test,_Ty&gt;::type)'
        with
        [
            _Ty=int
        ]
caffe2\aten\src\aten\core\boxing\KernelFunction_impl.h(67): note: With the following template arguments:
caffe2\aten\src\aten\core\boxing\KernelFunction_impl.h(67): note: 'Result=Return'
caffe2\aten\src\aten\core\boxing\KernelFunction_impl.h(67): note: 'Args={}'"><pre class="notranslate"><code class="notranslate">caffe2\aten\src\aten\core\boxing\KernelFunction_impl.h(67): error C2672: 'c10::impl::boxAndCallBoxedFunc': no matching overloaded function found
caffe2/aten/src\ATen/core/dispatch/Dispatcher.h(180): note: see reference to function template instantiation 'Return c10::KernelFunction::callUnboxed&lt;Return,const at::Tensor&amp;,const at::Tensor&amp;,bool,bool&gt;(const c10::OperatorHandle &amp;,const at::Tensor &amp;,const at::Tensor &amp;,bool,bool) const' being compiled
        with
        [
            Return=void
        ]
caffe2/aten/src\ATen/core/dispatch/Dispatcher.h(155): note: see reference to function template instantiation 'Return c10::Dispatcher::callUnboxed&lt;Return,const at::Tensor&amp;,const at::Tensor&amp;,bool,bool&gt;(const c10::OperatorHandle &amp;,const at::Tensor &amp;,const at::Tensor &amp;,bool,bool) const' being compiled
        with
        [
            Return=void
        ]
caffe2\ATen/core/TensorMethods.h(66): note: see reference to function template instantiation 'Return c10::OperatorHandle::callUnboxed&lt;void,const at::Tensor&amp;,const at::Tensor&amp;,bool,bool&gt;(const at::Tensor &amp;,const at::Tensor &amp;,bool,bool) const' being compiled
        with
        [
            Return=void
        ]
caffe2\aten\src\aten\core\boxing\KernelFunction_impl.h(67): error C2770: invalid explicit template argument(s) for 'Result c10::impl::boxAndCallBoxedFunc(c10::KernelFunction::InternalBoxedKernelFunction (__cdecl *),c10::OperatorKernel *,const c10::OperatorHandle &amp;,Args...,enable_if&lt;_Test,_Ty&gt;::type)'
        with
        [
            _Ty=int
        ]
caffe2/aten/src\ATen/core/boxing/boxing.h(53): note: see declaration of 'c10::impl::boxAndCallBoxedFunc'
caffe2\aten\src\aten\core\boxing\KernelFunction_impl.h(67): error C2893: Failed to specialize function template 'Result c10::impl::boxAndCallBoxedFunc(c10::KernelFunction::InternalBoxedKernelFunction (__cdecl *),c10::OperatorKernel *,const c10::OperatorHandle &amp;,Args...,enable_if&lt;_Test,_Ty&gt;::type)'
        with
        [
            _Ty=int
        ]
caffe2\aten\src\aten\core\boxing\KernelFunction_impl.h(67): note: With the following template arguments:
caffe2\aten\src\aten\core\boxing\KernelFunction_impl.h(67): note: 'Result=Return'
caffe2\aten\src\aten\core\boxing\KernelFunction_impl.h(67): note: 'Args={}'
</code></pre></div>
<p dir="auto">Error with /permissive-</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="nvcc_internal_extended_lambda_implementation(542): error C3861: 'args': identifier not found
caffe2/aten/src/ATen/native/cuda/Copy.cu(62): note: see reference to class template instantiation '__nv_hdl_create_wrapper_t&lt;false,true,__nv_dl_tag&lt;void (__cdecl *)(at::TensorIterator &amp;,bool),at::native::copy_device_to_device,1&gt;&gt;' being compiled"><pre class="notranslate"><code class="notranslate">nvcc_internal_extended_lambda_implementation(542): error C3861: 'args': identifier not found
caffe2/aten/src/ATen/native/cuda/Copy.cu(62): note: see reference to class template instantiation '__nv_hdl_create_wrapper_t&lt;false,true,__nv_dl_tag&lt;void (__cdecl *)(at::TensorIterator &amp;,bool),at::native::copy_device_to_device,1&gt;&gt;' being compiled
</code></pre></div>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">files compile</p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ezyang/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ezyang">@ezyang</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/gchanan/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/gchanan">@gchanan</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/zou3519/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/zou3519">@zou3519</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/yf225/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/yf225">@yf225</a> <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>