Error when building cpp extension

username: Looottch
cooked: <ul>
<li>OS: ubuntu 18.04</li>
<li>PyTorch version: 1.6</li>
<li>How you installed PyTorch (conda, pip, source): pip</li>
<li>Python version: 3.6</li>
<li>CUDA/cuDNN version: 10.1</li>
<li>GCC version (if compiling from source):7.4<br>
I am creating a custom c++ extension but I get an error on compiling when I add <span class="hashtag">#include</span> &lt;THC/THCAtomics.cuh&gt; in .h file and build through setup then it will have following errors:<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh: In member function ‘void AtomicAddIntegerImpl&lt;T, 1&gt;::operator()(T*, T)’:<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:31:13: error: there are no arguments to ‘atomicCAS’ that depend on a template parameter, so a declaration of ‘atomicCAS’ must be available [-fpermissive] old = atomicCAS(address_as_ui, assumed, newval);<br>
^~~~~~~~~<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:31:13: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh: In member function ‘void AtomicAddIntegerImpl&lt;T, 2&gt;::operator()(T*, T)’:<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:54:13: error: there are no arguments to ‘atomicCAS’ that depend on a template parameter, so a declaration of ‘atomicCAS’ must be available [-fpermissive] old = atomicCAS(address_as_ui, assumed, newval);<br>
^~~~~~~~~<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh: In member function ‘void AtomicAddIntegerImpl&lt;T, 4&gt;::operator()(T*, T)’:<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:70:13: error: there are no arguments to ‘atomicCAS’ that depend on a template parameter, so a declaration of ‘atomicCAS’ must be available [-fpermissive] old = atomicCAS(address_as_ui, assumed, newval);<br>
^~~~~~~~~<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh: In member function ‘void AtomicAddIntegerImpl&lt;T, 8&gt;::operator()(T*, T)’:<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:86:13: error: there are no arguments to ‘atomicCAS’ that depend on a template parameter, so a declaration of ‘atomicCAS’ must be available [-fpermissive] old = atomicCAS(address_as_ui, assumed, newval);<br>
^~~~~~~~~<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh: In function ‘void gpuAtomicAdd(int32_t*, int32_t)’: /usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:104:3: error: ‘atomicAdd’ was not declared in this scope<br>
atomicAdd(address, val);<br>
^~~~~~~~~<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:104:3: note: suggested alternative: ‘gpuAtomicAdd’ atomicAdd(address, val);<br>
^~~~~~~~~<br>
gpuAtomicAdd<br>
usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh: In function ‘void gpuAtomicAdd(c10::Half*, c10::Half)’:<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:135:5: error: ‘atomicAdd’ was not declared in this scope<br>
atomicAdd(reinterpret_cast&lt;__half*&gt;(address), val);<br>
^~~~~~~~~<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:135:5: note: suggested alternative: ‘gpuAtomicAdd’<br>
atomicAdd(reinterpret_cast&lt;__half*&gt;(address), val);<br>
^~~~~~~~~<br>
gpuAtomicAdd<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh: In function ‘void gpuAtomicAdd(c10::BFloat16*, c10::BFloat16)’:<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:152:13: error: ‘atomicCAS’ was not declared in this scope old = atomicCAS(address_as_ui, assumed, old);<br>
^~~~~~~~~<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh: In function 'void gpuAtomicAdd(double*, double ': /usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:198:3: error: ‘atomicAdd’ was not declared in this scope atomicAdd(address, val);<br>
^~~~~~~~~ /usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:198:3: note: suggested alternative: ‘gpuAtomicAdd’<br>
atomicAdd(address, val);<br>
^~~~~~~~~<br>
gpuAtomicAdd<br>
/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh: In function ‘void gpuAtomicAdd(float*, float)’:/usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:202:3: error: ‘atomicAdd’ was not declared in this scope atomicAdd(address, val);<br>
^~~~~~~~~ /usr/local/lib/python3.6/dist-packages/torch/include/THC/THCAtomics.cuh:202:3: note: suggested alternative: ‘gpuAtomicAdd’<br>
atomicAdd(address, val);<br>
^~~~~~~~~ gpuAtomicAdd</li>
</ul>