Repository: pytorch
Issue: Building NVCC (Device) failed when building from source
Labels: module: build,triaged

## 🐛 Bug

when i build Pytorch (1.4.1)from source in a conda env, i ran into this error

## To Reproduce

Steps to reproduce the behavior:

1. export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
2. python setup.py install

[1543/3479] Building NVCC (Device) object caffe2/CMakeFiles/torch.dir/operators/torch_generated_multi_class_accuracy_op.cu.o
FAILED: caffe2/CMakeFiles/torch.dir/operators/torch_generated_multi_class_accuracy_op.cu.o 
cd /home/pfyang/software/pytorch/build/caffe2/CMakeFiles/torch.dir/operators && /home/pfyang/miniconda3/envs/Pytorch14/bin/cmake -E make_directory /home/pfyang/software/pytorch/build/caffe2/CMakeFiles/torch.dir/operators/. && /home/pfyang/miniconda3/envs/Pytorch14/bin/cmake -D verbose:BOOL=OFF -D build_configuration:STRING=Release -D generated_file:STRING=/home/pfyang/software/pytorch/build/caffe2/CMakeFiles/torch.dir/operators/./torch_generated_multi_class_accuracy_op.cu.o -D generated_cubin_file:STRING=/home/pfyang/software/pytorch/build/caffe2/CMakeFiles/torch.dir/operators/./torch_generated_multi_class_accuracy_op.cu.o.cubin.txt -P /home/pfyang/software/pytorch/build/caffe2/CMakeFiles/torch.dir/operators/torch_generated_multi_class_accuracy_op.cu.o.Release.cmake
Segmentation fault (core dumped)
CMake Error at torch_generated_multi_class_accuracy_op.cu.o.Release.cmake:281 (message):
  Error generating file
  /home/pfyang/software/pytorch/build/caffe2/CMakeFiles/torch.dir/operators/./torch_generated_multi_class_accuracy_op.cu.o


[1549/3479] Building NVCC (Device) object caffe2/CMakeFiles/torch.dir/operators/torch_generated_reciprocal_op.cu.o
/home/pfyang/software/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 &) [with Packet=half2]"

[1550/3479] Building NVCC (Device) object caffe2/CMakeFiles/torch.dir/operators/torch_generated_normalize_ops.cu.o
/home/pfyang/software/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 &) [with Packet=half2]"

[1551/3479] Building NVCC (Device) object caffe2/CMakeFiles/torch.dir/operators/torch_generated_elementwise_div_op.cu.o
/home/pfyang/software/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 &) [with Packet=half2]"

[1552/3479] Building NVCC (Device) object caffe2/CMakeFiles/torch.dir/__/aten/src/THC/generated/torch_generated_THCTensorMathPointwiseShort.cu.o
FAILED: caffe2/CMakeFiles/torch.dir/__/aten/src/THC/generated/torch_generated_THCTensorMathPointwiseShort.cu.o 
cd /home/pfyang/software/pytorch/build/caffe2/CMakeFiles/torch.dir/__/aten/src/THC/generated && /home/pfyang/miniconda3/envs/Pytorch14/bin/cmake -E make_directory /home/pfyang/software/pytorch/build/caffe2/CMakeFiles/torch.dir/__/aten/src/THC/generated/. && /home/pfyang/miniconda3/envs/Pytorch14/bin/cmake -D verbose:BOOL=OFF -D build_configuration:STRING=Release -D generated_file:STRING=/home/pfyang/software/pytorch/build/caffe2/CMakeFiles/torch.dir/__/aten/src/THC/generated/./torch_generated_THCTensorMathPointwiseShort.cu.o -D generated_cubin_file:STRING=/home/pfyang/software/pytorch/build/caffe2/CMakeFiles/torch.dir/__/aten/src/THC/generated/./torch_generated_THCTensorMathPointwiseShort.cu.o.cubin.txt -P /home/pfyang/software/pytorch/build/caffe2/CMakeFiles/torch.dir/__/aten/src/THC/generated/torch_generated_THCTensorMathPointwiseShort.cu.o.Release.cmake
In file included from tmpxft_00005712_00000000-5_THCTensorMathPointwiseShort.cudafe1.stub.c:1:0:
/tmp/tmpxft_00005712_00000000-5_THCTensorMathPointwiseShort.cudafe1.stub.c: In function ‘void __device_stub__Z21kernelPointwiseApply3I18TensorCRemainderOpIsEsssjLin1ELi2ELi2EEv10OffsetInfoIT0_T3_XT4_EES2_IT1_S4_XT5_EES2_IT2_S4_XT6_EES4_T_(const _Z10OffsetInfoIsjLin1EE&, const _Z10OffsetInfoIsjLi2EE&, const _Z10OffsetInfoIsjLi2EE&, unsigned int, _Z18TensorCRemainderOpIsE&)’:
/tmp/tmpxft_00005712_00000000-5_THCTensorMathPointwiseShort.cudafe1.stub.c:1223:27: internal compiler error: Segmentation fault
 #pragma GCC diagnostic pop
                           ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
CMake Error at torch_generated_THCTensorMathPointwiseShort.cu.o.Release.cmake:281 (message):
  Error generating file
  /home/pfyang/software/pytorch/build/caffe2/CMakeFiles/torch.dir/__/aten/src/THC/generated/./torch_generated_THCTensorMathPointwiseShort.cu.o


[1554/3479] Building NVCC (Device) object caffe2/CMakeFiles/torch.dir/__/aten/src/THCUNN/torch_generated_HardTanh.cu.o
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "setup.py", line 755, in <module>
    build_deps()
  File "setup.py", line 316, in build_deps
    cmake=cmake)
  File "/home/pfyang/software/pytorch/tools/build_pytorch_libs.py", line 62, in build_caffe2
    cmake.build(my_env)
  File "/home/pfyang/software/pytorch/tools/setup_helpers/cmake.py", line 335, in build
    self.run(build_args, my_env)
  File "/home/pfyang/software/pytorch/tools/setup_helpers/cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/home/pfyang/miniconda3/envs/Pytorch14/lib/python3.6/subprocess.py", line 311, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '12']' returned non-zero exit status 1.


## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

## Environment

Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A

OS: Ubuntu 18.04.4 LTS
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
CMake version: version 3.17.0

Python version: 3.6
Is CUDA available: N/A
CUDA runtime version: 10.0.130
GPU models and configuration: GPU 0: GeForce RTX 2070
Nvidia driver version: 440.64.00
cuDNN version: Could not collect

Versions of relevant libraries:
[pip] numpy==1.18.4
[conda] magma-cuda100             2.5.2                         1    pytorch
[conda] mkl                       2020.1                      217    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
[conda] mkl-include               2020.1                      219    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
[conda] numpy                     1.18.4           py36h7314795_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge

## Additional context

any help will be appreciate


cc @malfet