Error: use the "typename" keyword to treat nontype "std::iterator_traits<_Iterator>

jiapei100: <p>Failed to build pytorch from the source.<br>
My <strong>ENV</strong>:</p>
<ul>
<li>Ubuntu 19.04</li>
<li>NVIDIA-SMI 430.40       Driver Version: 430.40       CUDA Version: 10.1</li>
<li>gcc (Ubuntu 8.3.0-6ubuntu1) 8.3.0</li>
</ul>
<pre><code class="lang-auto"> ^   
[501/2210] Building NVCC (Device) object caffe2/CMakeFiles/torch.dir/operators/torch_generated_pack_segments.cu.o
FAILED: caffe2/CMakeFiles/torch.dir/operators/torch_generated_pack_segments.cu.o 
cd ....../pytorch/build/caffe2/CMakeFiles/torch.dir/operators &amp;&amp; /usr/bin/cmake -E make_directory ....../pytorch/build/caffe2/CMakeFiles/torch.dir/operators/. &amp;&amp; /usr/bin/cmake -D verbose:BOOL=OFF -D build_configuration:STRING=Release -D generated_file:STRING=....../pytorch/build/caffe2/CMakeFiles/torch.dir/operators/./torch_generated_pack_segments.cu.o -D generated_cubin_file:STRING=....../pytorch/build/caffe2/CMakeFiles/torch.dir/operators/./torch_generated_pack_segments.cu.o.cubin.txt -P ....../pytorch/build/caffe2/CMakeFiles/torch.dir/operators/torch_generated_pack_segments.cu.o.Release.cmake
/usr/local/cuda/include/cub/device/dispatch/dispatch_reduce.cuh(362): error: use the "typename" keyword to treat nontype "std::iterator_traits&lt;_Iterator&gt;::value_type [with _Iterator=InputIteratorT]" as a type in a dependent context

/usr/local/cuda/include/cub/device/dispatch/dispatch_reduce.cuh(363): error: use the "typename" keyword to treat nontype "std::iterator_traits&lt;_Iterator&gt;::value_type [with _Iterator=OutputIteratorT]" as a type in a dependent context

/usr/local/cuda/include/cub/device/dispatch/dispatch_reduce.cuh(683): error: use the "typename" keyword to treat nontype "std::iterator_traits&lt;_Iterator&gt;::value_type [with _Iterator=InputIteratorT]" as a type in a dependent context

/usr/local/cuda/include/cub/device/dispatch/dispatch_reduce.cuh(684): error: use the "typename" keyword to treat nontype "std::iterator_traits&lt;_Iterator&gt;::value_type [with _Iterator=OutputIteratorT]" as a type in a dependent context

4 errors detected in the compilation of "/tmp/tmpxft_0000562a_00000000-6_pack_segments.cpp1.ii".
CMake Error at torch_generated_pack_segments.cu.o.Release.cmake:279 (message):
  Error generating file
  ....../pytorch/build/caffe2/CMakeFiles/torch.dir/operators/./torch_generated_pack_segments.cu.o


[502/2210] Building NVCC (Device) object caffe2/CMakeFiles/torch.dir/operators/torch_generated_logit_op.cu.o
....../pytorch/cmake/../third_party/eigen/Eigen/src/Core/arch/GPU/PacketMathHalf.h(149): warning: missing return statement at end of non-void function "Eigen::internal::ptrue(const Packet &amp;) [with Packet=half2]"

[508/2210] Building NVCC (Device) object caffe2/CMakeFiles/torch.dir/__/aten/src/THCUNN/torch_generated_LeakyReLU.cu.o
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "setup.py", line 748, in &lt;module&gt;
    build_deps()
  File "setup.py", line 321, in build_deps
    cmake=cmake)
  File "....../pytorch/tools/build_pytorch_libs.py", line 64, in build_caffe2
    cmake.build(my_env)
  File "....../pytorch/tools/setup_helpers/cmake.py", line 328, in build
    self.run(build_args, my_env)
  File "....../pytorch/tools/setup_helpers/cmake.py", line 133, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/usr/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '8']' returned non-zero exit status 1.
</code></pre>
<p>Any suggestions?</p>
<p>Cheers<br>
Pei</p>