Repository: pytorch
Issue: linking error when building on Linux
Labels: module: build,module: cuda,triaged

## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->

```
[11/457] Linking CXX executable bin/generate_proposals_op_util_nms_gpu_test
FAILED: bin/generate_proposals_op_util_nms_gpu_test 
: && /usr/bin/c++ -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow -DHAVE_AVX2_CPU_DEFINITION -O3 -DNDEBUG -DNDEBUG -rdynamic caffe2/CMakeFiles/generate_proposals_op_util_nms_gpu_test.dir/operators/generate_proposals_op_util_nms_gpu_test.cc.o -o bin/generate_proposals_op_util_nms_gpu_test  -Wl,-rpath,/home/me/miniconda3/envs/pytorch_build/lib:/home/me/project/pytorch/build/lib:  /usr/lib/x86_64-linux-gnu/libcudart.so  lib/libgtest_main.a  -Wl,--no-as-needed,"/home/me/project/pytorch/build/lib/libtorch.so" -Wl,--as-needed  -Wl,--no-as-needed,"/home/me/project/pytorch/build/lib/libtorch_cpu.so" -Wl,--as-needed  lib/libprotobuf.a  /home/me/miniconda3/envs/pytorch_build/lib/libmkl_intel_lp64.so  /home/me/miniconda3/envs/pytorch_build/lib/libmkl_gnu_thread.so  /home/me/miniconda3/envs/pytorch_build/lib/libmkl_core.so  -fopenmp  /usr/lib/x86_64-linux-gnu/libpthread.so  -lm  /usr/lib/x86_64-linux-gnu/libdl.so  lib/libdnnl.a  -ldl  -Wl,--no-as-needed,"/home/me/project/pytorch/build/lib/libtorch_cuda.so" -Wl,--as-needed  lib/libc10_cuda.so  lib/libc10.so  /usr/lib/x86_64-linux-gnu/libcudart.so  /usr/lib/x86_64-linux-gnu/libnvToolsExt.so  /usr/lib/x86_64-linux-gnu/libcufft.so  /usr/lib/x86_64-linux-gnu/libcurand.so  /usr/lib/x86_64-linux-gnu/libcublas.so  /usr/lib/x86_64-linux-gnu/libcudnn.so  lib/libgtest.a  -pthread && :
/usr/bin/ld: /home/me/project/pytorch/build/lib/libtorch_cuda.so: undefined reference to `void at::native::embedding_dense_backward_cuda_scan<int>(at::Tensor&, at::Tensor&)'
/usr/bin/ld: /home/me/project/pytorch/build/lib/libtorch_cuda.so: undefined reference to `at::native::index_put_with_sort_kernel_thrust_helper(at::Tensor&, at::Tensor&, at::Tensor&, long)'
/usr/bin/ld: /home/me/project/pytorch/build/lib/libtorch_cuda.so: undefined reference to `void at::native::embedding_dense_backward_cuda_scan<long>(at::Tensor&, at::Tensor&)'
```

## To Reproduce

Steps to reproduce the behavior:

1. export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"} ; python setup.py install
1.
1.

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

## Environment

Please copy and paste the output from our
[environment collection script](https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py)
(or fill out the checklist below manually).

You can get the script and run it with:
```
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```

Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.2 LTS (x86_64)
GCC version: (Ubuntu 8.4.0-3ubuntu2) 8.4.0
Clang version: Could not collect
CMake version: version 3.19.6
Libc version: glibc-2.31

Python version: 3.9.6 (default, Aug 18 2021, 19:38:01)  [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.11.0-34-generic-x86_64-with-glibc2.31
Is CUDA available: N/A
CUDA runtime version: 10.1.243
GPU models and configuration: GPU 0: NVIDIA GeForce GTX 1650
Nvidia driver version: 470.63.01
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.2.4
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.2.4
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.2.4
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.2.4
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.2.4
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.2.4
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.2.4
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.20.3
[conda] blas                      1.0                         mkl    defaults
[conda] magma-cuda101             2.5.2                         1    pytorch
[conda] mkl                       2021.3.0           h06a4308_520    defaults
[conda] mkl-include               2021.3.0           h06a4308_520    defaults
[conda] mkl-service               2.4.0            py39h7f8727e_0    defaults
[conda] mkl_fft                   1.3.0            py39h42c9631_2    defaults
[conda] mkl_random                1.2.2            py39h51133e4_0    defaults
[conda] numpy                     1.20.3           py39hf144106_0    defaults
[conda] numpy-base                1.20.3           py39h74d4b33_0    defaults


## Additional context

<!-- Add any other context about the problem here. -->


cc @malfet @seemethere @ngimel