Building PyTorch from Source NVCC Issue

username: kfallah
cooked: <p>Hello!</p>
<p>I have a Nvidia GTX 760 I am trying to use with PyTorch in Arch Linux. Searching online it appears I need to build from source. I have CUDA 10.2.89 installed with driver version 440.82.</p>
<p>If anyone has advice on how to fix this issue it would be appreciated.</p>
<pre><code class="lang-auto">[1656/2689] [1649/2689] Building NVCC (Device) object caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_elementwise_linear_op.cu.o
FAILED: caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_elementwise_linear_op.cu.o 
cd /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators &amp;&amp; /home/admin/.conda/envs/torch_gpu/bin/cmake -E make_directory /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/. &amp;&amp; /home/admin/.conda/envs/torch_gpu/bin/cmake -D verbose:BOOL=OFF -D build_configuration:STRING=Release -D generated_file:STRING=/home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_elementwise_linear_op.cu.o -D generated_cubin_file:STRING=/home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_elementwise_linear_op.cu.o.cubin.txt -P /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_elementwise_linear_op.cu.o.Release.cmake
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(164): error: expression must have a constant value
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(90): note: expression cannot be interpreted
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(110): note: called from:
          detected during:
            instantiation of "c10::string_view c10::util::get_fully_qualified_type_name&lt;T&gt;() [with T=caffe2::Tensor]" 
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/typeid.h(415): here
            instantiation of "c10::string_view caffe2::TypeMeta::TypeName&lt;T&gt;() [with T=caffe2::Tensor]" 
/home/admin/.conda/envs/torch_gpu/pytorch/caffe2/core/blob.h(88): here

1 error detected in the compilation of "/tmp/tmpxft_00007942_00000000-4_elementwise_linear_op.cpp4.ii".
CMake Error at torch_cuda_generated_elementwise_linear_op.cu.o.Release.cmake:281 (message):
  Error generating file
  /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_elementwise_linear_op.cu.o


[1650/2689] Building NVCC (Device) object caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_enforce_finite_op.cu.o
FAILED: caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_enforce_finite_op.cu.o 
cd /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators &amp;&amp; /home/admin/.conda/envs/torch_gpu/bin/cmake -E make_directory /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/. &amp;&amp; /home/admin/.conda/envs/torch_gpu/bin/cmake -D verbose:BOOL=OFF -D build_configuration:STRING=Release -D generated_file:STRING=/home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_enforce_finite_op.cu.o -D generated_cubin_file:STRING=/home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_enforce_finite_op.cu.o.cubin.txt -P /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_enforce_finite_op.cu.o.Release.cmake
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(164): error: expression must have a constant value
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(90): note: expression cannot be interpreted
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(110): note: called from:
          detected during:
            instantiation of "c10::string_view c10::util::get_fully_qualified_type_name&lt;T&gt;() [with T=caffe2::Tensor]" 
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/typeid.h(415): here
            instantiation of "c10::string_view caffe2::TypeMeta::TypeName&lt;T&gt;() [with T=caffe2::Tensor]" 
/home/admin/.conda/envs/torch_gpu/pytorch/caffe2/core/blob.h(88): here

1 error detected in the compilation of "/tmp/tmpxft_00007938_00000000-4_enforce_finite_op.cpp4.ii".
CMake Error at torch_cuda_generated_enforce_finite_op.cu.o.Release.cmake:281 (message):
  Error generating file
  /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_enforce_finite_op.cu.o


[1651/2689] Building NVCC (Device) object caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_filler_op.cu.o
FAILED: caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_filler_op.cu.o 
cd /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators &amp;&amp; /home/admin/.conda/envs/torch_gpu/bin/cmake -E make_directory /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/. &amp;&amp; /home/admin/.conda/envs/torch_gpu/bin/cmake -D verbose:BOOL=OFF -D build_configuration:STRING=Release -D generated_file:STRING=/home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_filler_op.cu.o -D generated_cubin_file:STRING=/home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_filler_op.cu.o.cubin.txt -P /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_filler_op.cu.o.Release.cmake
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(164): error: expression must have a constant value
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(90): note: expression cannot be interpreted
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(110): note: called from:
          detected during:
            instantiation of "c10::string_view c10::util::get_fully_qualified_type_name&lt;T&gt;() [with T=caffe2::Tensor]" 
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/typeid.h(415): here
            instantiation of "c10::string_view caffe2::TypeMeta::TypeName&lt;T&gt;() [with T=caffe2::Tensor]" 
/home/admin/.conda/envs/torch_gpu/pytorch/caffe2/core/blob.h(88): here

1 error detected in the compilation of "/tmp/tmpxft_00007948_00000000-4_filler_op.cpp4.ii".
CMake Error at torch_cuda_generated_filler_op.cu.o.Release.cmake:281 (message):
  Error generating file
  /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_filler_op.cu.o


[1652/2689] Building NVCC (Device) object caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_cross_entropy_op.cu.o
FAILED: caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_cross_entropy_op.cu.o 
cd /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators &amp;&amp; /home/admin/.conda/envs/torch_gpu/bin/cmake -E make_directory /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/. &amp;&amp; /home/admin/.conda/envs/torch_gpu/bin/cmake -D verbose:BOOL=OFF -D build_configuration:STRING=Release -D generated_file:STRING=/home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_cross_entropy_op.cu.o -D generated_cubin_file:STRING=/home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_cross_entropy_op.cu.o.cubin.txt -P /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_cross_entropy_op.cu.o.Release.cmake
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(164): error: expression must have a constant value
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(90): note: expression cannot be interpreted
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(110): note: called from:
          detected during:
            instantiation of "c10::string_view c10::util::get_fully_qualified_type_name&lt;T&gt;() [with T=caffe2::Tensor]" 
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/typeid.h(415): here
            instantiation of "c10::string_view caffe2::TypeMeta::TypeName&lt;T&gt;() [with T=caffe2::Tensor]" 
/home/admin/.conda/envs/torch_gpu/pytorch/caffe2/core/blob.h(88): here

1 error detected in the compilation of "/tmp/tmpxft_00007950_00000000-4_cross_entropy_op.cpp4.ii".
CMake Error at torch_cuda_generated_cross_entropy_op.cu.o.Release.cmake:281 (message):
  Error generating file
  /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_cross_entropy_op.cu.o


[1653/2689] Building NVCC (Device) object caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_elementwise_mul_op.cu.o
FAILED: caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_elementwise_mul_op.cu.o 
cd /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators &amp;&amp; /home/admin/.conda/envs/torch_gpu/bin/cmake -E make_directory /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/. &amp;&amp; /home/admin/.conda/envs/torch_gpu/bin/cmake -D verbose:BOOL=OFF -D build_configuration:STRING=Release -D generated_file:STRING=/home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_elementwise_mul_op.cu.o -D generated_cubin_file:STRING=/home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_elementwise_mul_op.cu.o.cubin.txt -P /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_elementwise_mul_op.cu.o.Release.cmake
/home/admin/.conda/envs/torch_gpu/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]"

/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(164): error: expression must have a constant value
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(90): note: expression cannot be interpreted
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/TypeIndex.h(110): note: called from:
          detected during:
            instantiation of "c10::string_view c10::util::get_fully_qualified_type_name&lt;T&gt;() [with T=caffe2::Tensor]" 
/home/admin/.conda/envs/torch_gpu/pytorch/c10/util/typeid.h(415): here
            instantiation of "c10::string_view caffe2::TypeMeta::TypeName&lt;T&gt;() [with T=caffe2::Tensor]" 
/home/admin/.conda/envs/torch_gpu/pytorch/caffe2/core/blob.h(88): here

1 error detected in the compilation of "/tmp/tmpxft_00007973_00000000-4_elementwise_mul_op.cpp4.ii".
CMake Error at torch_cuda_generated_elementwise_mul_op.cu.o.Release.cmake:281 (message):
  Error generating file
  /home/admin/.conda/envs/torch_gpu/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/operators/./torch_cuda_generated_elementwise_mul_op.cu.o


[1656/2689] Building NVCC (Device) object caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/THC/torch_cuda_generated_THCTensorMathPairwise.cu.o
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "setup.py", line 738, in &lt;module&gt;
    build_deps()
  File "setup.py", line 315, in build_deps
    build_caffe2(version=version,
  File "/home/admin/.conda/envs/torch_gpu/pytorch/tools/build_pytorch_libs.py", line 62, in build_caffe2
    cmake.build(my_env)
  File "/home/admin/.conda/envs/torch_gpu/pytorch/tools/setup_helpers/cmake.py", line 340, in build
    self.run(build_args, my_env)
  File "/home/admin/.conda/envs/torch_gpu/pytorch/tools/setup_helpers/cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/home/admin/.conda/envs/torch_gpu/lib/python3.8/subprocess.py", line 364, 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>

username: ptrblck
cooked: <p>Could you try to use <a href="https://github.com/pytorch/pytorch/issues/32770#issuecomment-609093699">this workaround</a> and report your issue additionally in the linked bug?</p>

username: kfallah
cooked: <p>Thanks for your reply! For anyone coming back to this, I was able to fix by re-cloning the repository, recursively.</p>