#error "Expected GLOO_USE_CUDA to be defined"

RIk_Kumar: <p>i am getting the below error when installing pytorch from the github repository.<br>
<br>
[ 69%] Linking CXX static library libgloo.a<br>
[ 69%] Built target gloo<br>
[ 80%] Building NVCC (Device) object gloo/CMakeFiles/gloo_cuda.dir/gloo_cuda_generated_cuda_private.cu.o<br>
[ 76%] Building NVCC (Device) object gloo/CMakeFiles/gloo_cuda.dir/gloo_cuda_generated_cuda.cu.o<br>
[ 80%] Building NVCC (Device) object gloo/CMakeFiles/gloo_cuda.dir/nccl/gloo_cuda_generated_nccl.cu.o<br>
In file included from /u/hk/pytorch/torch/lib/gloo/gloo/cuda_private.h:16:0,<br>
from /u/hk/pytorch/torch/lib/gloo/gloo/cuda_private.cu:10:<br>
/u/hk/pytorch/torch/lib/gloo/gloo/cuda.h:24:2: error: <span class="hashtag">#error</span> “Expected GLOO_USE_CUDA to be defined”<br>
<span class="hashtag">#error</span> “Expected GLOO_USE_CUDA to be defined”<br>
^<br>
In file included from /u/hk/pytorch/torch/lib/gloo/gloo/cuda.cu:10:0:<br>
/u/hk/pytorch/torch/lib/gloo/gloo/cuda.h:24:2: error: <span class="hashtag">#error</span> “Expected GLOO_USE_CUDA to be defined”<br>
<span class="hashtag">#error</span> “Expected GLOO_USE_CUDA to be defined”<br>
^<br>
CMake Error at gloo_cuda_generated_cuda_private.cu.o.cmake:203 (message):<br>
Error generating<br>
/u/hk/pytorch/torch/lib/build/gloo/gloo/CMakeFiles/gloo_cuda.dir//./gloo_cuda_generated_cuda_private.cu.o</p>
<p>make[2]: *** [gloo/CMakeFiles/gloo_cuda.dir/gloo_cuda_generated_cuda_private.cu.o] Error 1<br>
make[2]: *** Waiting for unfinished jobs…<br>
CMake Error at gloo_cuda_generated_cuda.cu.o.cmake:203 (message):<br>
Error generating<br>
/u/hk/pytorch/torch/lib/build/gloo/gloo/CMakeFiles/gloo_cuda.dir//./gloo_cuda_generated_cuda.cu.o</p>
<p>make[2]: *** [gloo/CMakeFiles/gloo_cuda.dir/gloo_cuda_generated_cuda.cu.o] Error 1<br>
In file included from /u/hk/pytorch/torch/lib/gloo/gloo/nccl/nccl.h:18:0,<br>
from /u/hk/pytorch/torch/lib/gloo/gloo/nccl/nccl.cu:10:<br>
/u/hk/pytorch/torch/lib/gloo/gloo/cuda.h:24:2: error: <span class="hashtag">#error</span> “Expected GLOO_USE_CUDA to be defined”<br>
<span class="hashtag">#error</span> “Expected GLOO_USE_CUDA to be defined”<br>
^<br>
CMake Error at gloo_cuda_generated_nccl.cu.o.cmake:203 (message):<br>
Error generating<br>
/u/hk/pytorch/torch/lib/build/gloo/gloo/CMakeFiles/gloo_cuda.dir/nccl/./gloo_cuda_generated_nccl.cu.o</p>
<p>make[2]: *** [gloo/CMakeFiles/gloo_cuda.dir/nccl/gloo_cuda_generated_nccl.cu.o] Error 1<br>
make[1]: *** [gloo/CMakeFiles/gloo_cuda.dir/all] Error 2<br>
make: *** [all] Error 2<br>
</p>

smth: <p>i’ll look into it now, the continuous builds pass for some reason.<br>
What version of CUDA are you using? What’s the output of the command <code>nvcc --version</code>?</p>
<p>For a workaround use:</p>
<pre><code class="lang-auto">NO_DISTRIBUTED=1 python setup.py install
</code></pre>

pvskand: <p>Even I am getting the same error when I run <code>python setup.py install</code></p>
<p><code>nvcc --version</code> output :<br>
<code>nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2015 NVIDIA Corporation Built on Tue_Aug_11_14:27:32_CDT_2015 Cuda compilation tools, release 7.5, V7.5.17</code><br>
PS : <code>NO_DISTRIBUTED=1 python setup.py install</code> is working but my question is what is <code>NO_DISTRIBUTED=1</code> for?</p>
<p>Edit 1: As I previously mentioned, I have installed it via <code>NO_DISTRIBUTED=1 python setup.py install</code> but am unable to user <code>affine_grid</code> function.</p>

VioletPeng: <p>I’m experiencing the same problem. Trying to install on a linux machine which I do not have root privilege.<br>
NO_DISTRIBUTED=1 will install but cannot link against the existing cuda.<br>
my nvcc --version:<br>
nvcc: NVIDIA ® Cuda compiler driver<br>
Copyright © 2005-2016 NVIDIA Corporation<br>
Built on Sun_Sep__4_22:14:01_CDT_2016<br>
Cuda compilation tools, release 8.0, V8.0.44</p>

tyoc213: <p>Im having same problem, how we can solve the real problem of gloo library development files?</p>
<p>I guess something related to <a href="https://code.ihub.org.cn/projects/123/repositories/159/file_edit_page?file_name=FindGloo.cmake&amp;path=cmake%2FModules%2FFindGloo.cmake&amp;rev=master" rel="noopener nofollow ugc">https://code.ihub.org.cn/projects/123/repositories/159/file_edit_page?file_name=FindGloo.cmake&amp;path=cmake%2FModules%2FFindGloo.cmake&amp;rev=master</a> (which I downloaded and can compile on my own)</p>
<p>Also I guess this is the library? <a href="https://github.com/facebookincubator/gloo" class="inline-onebox" rel="noopener nofollow ugc">GitHub - facebookincubator/gloo: Collective communications library with various primitives for multi-machine training.</a></p>
<p>But the point it is that is inside the third party libs</p>
<pre><code class="lang-auto">[ 22%] Building NVCC (Device) object third_party/gloo/gloo/CMakeFiles/gloo_cuda.dir/gloo_cuda_generated_cuda.cu.o
    In file included from /home/tyoc213/Documents/github/pytorch/third_party/gloo/gloo/cuda_private.cu:9:
    In file included from /home/tyoc213/Documents/github/pytorch/torch/include/gloo/cuda_private.h:20:
    /home/tyoc213/Documents/github/pytorch/torch/include/gloo/cuda.h:24:2: error: "Expected GLOO_USE_CUDA to be defined"
    #error "Expected GLOO_USE_CUDA to be defined"
     ^
    In file included from /home/tyoc213/Documents/github/pytorch/third_party/gloo/gloo/cuda.cu:9:
    /home/tyoc213/Documents/github/pytorch/torch/include/gloo/cuda.h:24:2: error: "Expected GLOO_USE_CUDA to be defined"
    #error "Expected GLOO_USE_CUDA to be defined"
     ^
    1 error generated.
    CMake Error at gloo_cuda_generated_cuda_private.cu.o.Release.cmake:217 (message):
      Error generating
      /home/tyoc213/Documents/github/pytorch/build/third_party/gloo/gloo/CMakeFiles/gloo_cuda.dir//./gloo_cuda_generated_cuda_private.cu.o


    make[2]: *** [third_party/gloo/gloo/CMakeFiles/gloo_cuda.dir/build.make:91: third_party/gloo/gloo/CMakeFiles/gloo_cuda.dir/gloo_cuda_generated_cuda_private.cu.o] Error 1
    make[2]: *** Waiting for unfinished jobs....
    Scanning dependencies of target dnnl
    1 error generated.
    CMake Error at gloo_cuda_generated_cuda.cu.o.Release.cmake:217 (message):
      Error generating
      /home/tyoc213/Documents/github/pytorch/build/third_party/gloo/gloo/CMakeFiles/gloo_cuda.dir//./gloo_cuda_generated_cuda.cu.o


    make[2]: *** [third_party/gloo/gloo/CMakeFiles/gloo_cuda.dir/build.make:84: third_party/gloo/gloo/CMakeFiles/gloo_cuda.dir/gloo_cuda_generated_cuda.cu.o] Error 1
    make[1]: *** [CMakeFiles/Makefile2:3734: third_party/gloo/gloo/CMakeFiles/gloo_cuda.dir/all] Error 2
    make[1]: *** Waiting for unfinished jobs....

</code></pre>