Error while compiling PyTorch 1.7.1 with Cuda 11.1

username: Muhammad_Maaz
cooked: <p>OS: Ubuntu 20.04.2 LTS<br>
Python Version: 3.8.10<br>
GPU: RTX A6000<br>
Cuda Version: 11.1, V11.1.74<br>
CuDNN Version: 8.0.5<br>
magma-cuda111 2.5.2<br>
PyTorch: v1.7.1-rc3</p>
<pre><code class="lang-auto">/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(26): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(27): error: variable "THC_API" is not a type name

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(27): error: variable "uint8_t" has already been defined

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(27): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(29): error: variable "THC_API" is not a type name

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(29): error: namespace "at" has no actual member "StorageImpl"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(29): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(30): error: variable "THC_API" is not a type name

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(30): error: namespace "at" has no actual member "StorageImpl"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(30): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(31): error: variable "THC_API" is not a type name

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(31): error: namespace "at" has no actual member "StorageImpl"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(31): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(32): error: variable "THC_API" is not a type name

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(32): error: namespace "at" has no actual member "StorageImpl"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(32): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(34): error: variable "THC_API" is not a type name

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(34): error: namespace "at" has no actual member "StorageImpl"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(34): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(37): error: variable "THC_API" is not a type name

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(37): error: namespace "at" has no actual member "StorageImpl"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(37): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(41): error: this declaration has no storage class or type specifier

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(41): error: variable "THC_API" has already been defined

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(41): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(42): error: this declaration has no storage class or type specifier

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(42): error: variable "THC_API" has already been defined

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(42): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(43): error: this declaration has no storage class or type specifier

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(43): error: variable "THC_API" has already been defined

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(43): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(45): error: this declaration has no storage class or type specifier

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(45): error: variable "THC_API" has already been defined

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(45): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(46): error: this declaration has no storage class or type specifier

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(46): error: variable "THC_API" has already been defined

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(46): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(48): error: this declaration has no storage class or type specifier

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(48): error: variable "THC_API" has already been defined

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(48): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(50): error: this declaration has no storage class or type specifier

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(50): error: variable "THC_API" has already been defined

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(50): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(22): error: variable "THC_API" is not a type name

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(22): error: "int8_t" has already been declared in the current scope

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(22): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(23): error: this declaration has no storage class or type specifier

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(23): error: variable "THC_API" has already been defined

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(23): error: expected a ";"

/tmp/tmp/pytorch/aten/src/THC/generic/THCStorage.h(26): error: this declaration has no storage class or type specifier

Error limit reached.
100 errors detected in the compilation of "/tmp/tmp/pytorch/aten/src/ATen/native/cuda/DistanceKernel.cu".
Compilation terminated.
CMake Error at torch_cuda_generated_DistanceKernel.cu.o.Release.cmake:281 (message):
  Error generating file
  /tmp/tmp/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/ATen/native/cuda/./torch_cuda_generated_DistanceKernel.cu.o


[4006/4993] Building NVCC (Device) object caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/ATen/native/cuda/torch_cuda_generated_BinaryLogicalOpsKernels.cu.o
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "setup.py", line 760, in &lt;module&gt;
    build_deps()
  File "setup.py", line 310, in build_deps
    build_caffe2(version=version,
  File "/tmp/tmp/pytorch/tools/build_pytorch_libs.py", line 62, in build_caffe2
    cmake.build(my_env)
  File "/tmp/tmp/pytorch/tools/setup_helpers/cmake.py", line 345, in build
    self.run(build_args, my_env)
  File "/tmp/tmp/pytorch/tools/setup_helpers/cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/home/oreo/anaconda3/envs/pytorch_1.7/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '128']' returned non-zero exit status 1.
</code></pre>

username: ptrblck
cooked: <p>Could you update to a stable tag (you are currently using <code>1.7.1-rc3</code>) or the current master and try to rebuild? I’m unsure, if your current version had known issues during the build.</p>

username: Muhammad_Maaz
cooked: <p>I tried to use the tag <code>v1.7.1</code> and got the same error. Switching to current master compiles successfully but I in fact need PyTorch 1.7.</p>

username: ptrblck
cooked: <p>Unfortunately, I cannot reproduce the build issue and was able to rebuild <code>v1.7.1</code> with CUDA11.1 just now.</p>