Repository: pytorch
Issue: Trying to compile PyTorch for sm_30 fails with `error: identifier “__ldg” is undefined`
Labels: module: build,module: cuda,triaged

## ❓ Questions and Help

Hi, after I run “python setup.py install”, I get this error :

[3894/5004] Building NVCC (Device) obj…cuda_generated_THCTensorTopKShort.cu.o
FAILED: caffe2/CMakeFiles/torch_cuda.dir//aten/src/THC/generated/torch_cuda_generated_THCTensorTopKShort.cu.o
cd /home/ionur1/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir//aten/src/THC/generated && /home/ionur1/anaconda3/envs/conda_env/bin/cmake -E make_directory /home/ionur1/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir//aten/src/THC/generated/. && /home/ionur1/anaconda3/envs/conda_env/bin/cmake -D verbose:BOOL=OFF -D build_configuration:STRING=Release -D generated_file:STRING=/home/ionur1/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir//aten/src/THC/generated/./torch_cuda_generated_THCTensorTopKShort.cu.o -D generated_cubin_file:STRING=/home/ionur1/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir//aten/src/THC/generated/./torch_cuda_generated_THCTensorTopKShort.cu.o.cubin.txt -P /home/ionur1/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir//aten/src/THC/generated/torch_cuda_generated_THCTensorTopKShort.cu.o.Release.cmake
/home/ionur1/pytorch/aten/src/THC/THCDeviceUtils.cuh(38): error: identifier “__ldg” is undefined
detected during:
instantiation of “T doLdg(const T *) [with T=int16_t]”
/home/ionur1/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=int16_t, bitwise_t=uint32_t, index_t=uint32_t, CountType=int, RadixSize=4, RadixBits=2]”
/home/ionur1/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=int16_t, bitwise_t=uint32_t, index_t=uint32_t, Order=true]”
/home/ionur1/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=int16_t, IndexType=uint32_t, Dim=1, Order=true]”
/home/ionur1/pytorch/aten/src/THC/generic/THCTensorTopK.cu(127): here

1 error detected in the compilation of “/tmp/tmpxft_0000297e_00000000-6_THCTensorTopKShort.cpp1.ii”.
CMake Error at torch_cuda_generated_THCTensorTopKShort.cu.o.Release.cmake:281 (message):
Error generating file
/home/ionur1/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/THC/generated/./torch_cuda_generated_THCTensorTopKShort.cu.o

[3901/5004] Building NVCC (Device) obj…rch_cuda_generated_THCTensorIndex.cu.o
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File “setup.py”, line 724, in
build_deps()
File “setup.py”, line 312, in build_deps
build_caffe2(version=version,
File “/home/ionur1/pytorch/tools/build_pytorch_libs.py”, line 62, in build_caffe2
cmake.build(my_env)
File “/home/ionur1/pytorch/tools/setup_helpers/cmake.py”, line 346, in build
self.run(build_args, my_env)
File “/home/ionur1/pytorch/tools/setup_helpers/cmake.py”, line 141, in run
check_call(command, cwd=self.build_dir, env=env)
File “/home/ionur1/anaconda3/envs/conda_env/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.

Note: I tried to run with python and python3, nothing has changed. I activated Conda environment before running the commands.

OS: Ubuntu 18.04.1 LTS
CUDA Version 10.2.89
cudNN Version 7603
Python : 3.8.5
GPU : GPU0 Quadro K3100M
GCC version : 8.4.0

I would like to be very glad if you help me with this.


cc @malfet @seemethere @walterddr @ngimel