Building fails while installing pytorch from source

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.

These are installed:
nvidia driver: 418.113
cuda: 10.1
cudnn: 8.0.4.30

I followed the instructions on https://github.com/pytorch/pytorch#from-source
and the line below before starting the installation.

$ export TORCH_CUDA_ARCH_LIST=3.0

Error:

[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 && /home/srv/anaconda3/bin/cmake -E make_directory /home/srv/anaconda3/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/THC/generated/. && /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<scalar_t,bitwise_t,index_t,CountType,RadixSize,RadixBits>(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<scalar_t,bitwise_t,index_t,Order>(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<T,IndexType,Dim,Order>(TensorInfo<T, IndexType>, IndexType, IndexType, IndexType, IndexType, TensorInfo<T, IndexType>, IndexType, IndexType, TensorInfo<int64_t, IndexType>, 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 <module>
    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.

The warning at the beginning:

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)

I don’t think you can compile for compute capability 3.0, as __ldg() is defined for >=3.5 as described here.