Building fails while installing pytorch from source

username: svrc
cooked: <p>I am trying to install pytorch from source because my gpus compute capability is 3.0. I get the error below for different files each time. Also, there is a warning at the beginning.</p>
<p>These are installed:<br>
nvidia driver: 418.113<br>
cuda: 10.1<br>
cudnn: 8.0.4.30</p>
<p>I followed the instructions on <a href="https://github.com/pytorch/pytorch#from-source" rel="noopener nofollow ugc">https://github.com/pytorch/pytorch#from-source</a><br>
and the line below before starting the installation.</p>
<pre><code class="lang-auto">$ export TORCH_CUDA_ARCH_LIST=3.0
</code></pre>
<p>Error:</p>
<pre><code class="lang-auto">[38/1087] Building NVCC (Device) object caffe2/CMakeFiles/torch...n/src/THC/generated/torch_cuda_generated_THCTensorTopKChar.cu.o
FAILED: caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/THC/generated/torch_cuda_generated_THCTensorTopKChar.cu.o 
cd /home/srv/anaconda3/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/THC/generated &amp;&amp; /home/srv/anaconda3/bin/cmake -E make_directory /home/srv/anaconda3/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/THC/generated/. &amp;&amp; /home/srv/anaconda3/bin/cmake -D verbose:BOOL=OFF -D build_configuration:STRING=Release -D generated_file:STRING=/home/srv/anaconda3/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/THC/generated/./torch_cuda_generated_THCTensorTopKChar.cu.o -D generated_cubin_file:STRING=/home/srv/anaconda3/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/THC/generated/./torch_cuda_generated_THCTensorTopKChar.cu.o.cubin.txt -P /home/srv/anaconda3/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/THC/generated/torch_cuda_generated_THCTensorTopKChar.cu.o.Release.cmake
/home/srv/anaconda3/pytorch/aten/src/THC/THCDeviceUtils.cuh(38): error: identifier "__ldg" is undefined
          detected during:
            instantiation of "T doLdg(const T *) [with T=int8_t]" 
/home/srv/anaconda3/pytorch/aten/src/ATen/native/cuda/SortingRadixSelect.cuh(201): here
            instantiation of "void at::native::countRadixUsingMask&lt;scalar_t,bitwise_t,index_t,CountType,RadixSize,RadixBits&gt;(CountType *, CountType *, bitwise_t, bitwise_t, int, index_t, index_t, scalar_t *) [with scalar_t=int8_t, bitwise_t=uint32_t, index_t=uint32_t, CountType=int, RadixSize=4, RadixBits=2]" 
/home/srv/anaconda3/pytorch/aten/src/ATen/native/cuda/SortingRadixSelect.cuh(337): here
            instantiation of "void at::native::radixSelect&lt;scalar_t,bitwise_t,index_t,Order&gt;(scalar_t *, index_t, index_t, index_t, int *, scalar_t *) [with scalar_t=int8_t, bitwise_t=uint32_t, index_t=uint32_t, Order=true]" 
/home/srv/anaconda3/pytorch/aten/src/THC/THCTensorTopK.cuh(69): here
            instantiation of "void gatherTopK&lt;T,IndexType,Dim,Order&gt;(TensorInfo&lt;T, IndexType&gt;, IndexType, IndexType, IndexType, IndexType, TensorInfo&lt;T, IndexType&gt;, IndexType, IndexType, TensorInfo&lt;int64_t, IndexType&gt;, IndexType) [with T=int8_t, IndexType=uint32_t, Dim=1, Order=true]" 
/home/srv/anaconda3/pytorch/aten/src/THC/generic/THCTensorTopK.cu(127): here

1 error detected in the compilation of "/tmp/tmpxft_0000040e_00000000-6_THCTensorTopKChar.cpp1.ii".
CMake Error at torch_cuda_generated_THCTensorTopKChar.cu.o.Release.cmake:281 (message):
  Error generating file
  /home/srv/anaconda3/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/THC/generated/./torch_cuda_generated_THCTensorTopKChar.cu.o


[45/1087] Building NVCC (Device) object caffe2/CMakeFiles/torch...__/aten/src/THC/torch_cuda_generated_THCTensorMathPairwise.cu.o
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "setup.py", line 724, in &lt;module&gt;
    build_deps()
  File "setup.py", line 312, in build_deps
    build_caffe2(version=version,
  File "/home/srv/anaconda3/pytorch/tools/build_pytorch_libs.py", line 62, in build_caffe2
    cmake.build(my_env)
  File "/home/srv/anaconda3/pytorch/tools/setup_helpers/cmake.py", line 346, in build
    self.run(build_args, my_env)
  File "/home/srv/anaconda3/pytorch/tools/setup_helpers/cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/home/srv/anaconda3/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>
<p>The warning at the beginning:</p>
<pre><code class="lang-auto">CMake Warning at caffe2/CMakeLists.txt:700 (add_library):
  Cannot generate a safe runtime search path for target torch_cpu because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libgomp.so.1] in /usr/lib/gcc/x86_64-linux-gnu/7 may be hidden by files in:
      /home/srv/anaconda3/lib

  Some of these libraries may not be found correctly.


CMake Warning at cmake/Modules_CUDA_fix/upstream/FindCUDA.cmake:1854 (add_library):
  Cannot generate a safe runtime search path for target
  caffe2_detectron_ops_gpu because files in some directories may conflict
  with libraries in implicit directories:

    runtime library [libgomp.so.1] in /usr/lib/gcc/x86_64-linux-gnu/7 may be hidden by files in:
      /home/srv/anaconda3/lib

  Some of these libraries may not be found correctly.
Call Stack (most recent call first):
  modules/detectron/CMakeLists.txt:13 (CUDA_ADD_LIBRARY)

</code></pre>

username: ptrblck
cooked: <p>I don’t think you can compile for compute capability 3.0, as <code>__ldg()</code> is defined for &gt;=3.5 as described <a href="https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#ldg-function">here</a>.</p>