#error "Expected GLOO_USE_CUDA to be defined"

i am getting the below error when installing pytorch from the github repository.

[ 69%] Linking CXX static library libgloo.a
[ 69%] Built target gloo
[ 80%] Building NVCC (Device) object gloo/CMakeFiles/gloo_cuda.dir/gloo_cuda_generated_cuda_private.cu.o
[ 76%] Building NVCC (Device) object gloo/CMakeFiles/gloo_cuda.dir/gloo_cuda_generated_cuda.cu.o
[ 80%] Building NVCC (Device) object gloo/CMakeFiles/gloo_cuda.dir/nccl/gloo_cuda_generated_nccl.cu.o
In file included from /u/hk/pytorch/torch/lib/gloo/gloo/cuda_private.h:16:0,
from /u/hk/pytorch/torch/lib/gloo/gloo/cuda_private.cu:10:
/u/hk/pytorch/torch/lib/gloo/gloo/cuda.h:24:2: error: #error “Expected GLOO_USE_CUDA to be defined”
#error “Expected GLOO_USE_CUDA to be defined”
^
In file included from /u/hk/pytorch/torch/lib/gloo/gloo/cuda.cu:10:0:
/u/hk/pytorch/torch/lib/gloo/gloo/cuda.h:24:2: error: #error “Expected GLOO_USE_CUDA to be defined”
#error “Expected GLOO_USE_CUDA to be defined”
^
CMake Error at gloo_cuda_generated_cuda_private.cu.o.cmake:203 (message):
Error generating
/u/hk/pytorch/torch/lib/build/gloo/gloo/CMakeFiles/gloo_cuda.dir//./gloo_cuda_generated_cuda_private.cu.o

make[2]: *** [gloo/CMakeFiles/gloo_cuda.dir/gloo_cuda_generated_cuda_private.cu.o] Error 1
make[2]: *** Waiting for unfinished jobs…
CMake Error at gloo_cuda_generated_cuda.cu.o.cmake:203 (message):
Error generating
/u/hk/pytorch/torch/lib/build/gloo/gloo/CMakeFiles/gloo_cuda.dir//./gloo_cuda_generated_cuda.cu.o

make[2]: *** [gloo/CMakeFiles/gloo_cuda.dir/gloo_cuda_generated_cuda.cu.o] Error 1
In file included from /u/hk/pytorch/torch/lib/gloo/gloo/nccl/nccl.h:18:0,
from /u/hk/pytorch/torch/lib/gloo/gloo/nccl/nccl.cu:10:
/u/hk/pytorch/torch/lib/gloo/gloo/cuda.h:24:2: error: #error “Expected GLOO_USE_CUDA to be defined”
#error “Expected GLOO_USE_CUDA to be defined”
^
CMake Error at gloo_cuda_generated_nccl.cu.o.cmake:203 (message):
Error generating
/u/hk/pytorch/torch/lib/build/gloo/gloo/CMakeFiles/gloo_cuda.dir/nccl/./gloo_cuda_generated_nccl.cu.o

make[2]: *** [gloo/CMakeFiles/gloo_cuda.dir/nccl/gloo_cuda_generated_nccl.cu.o] Error 1
make[1]: *** [gloo/CMakeFiles/gloo_cuda.dir/all] Error 2
make: *** [all] Error 2

i’ll look into it now, the continuous builds pass for some reason.
What version of CUDA are you using? What’s the output of the command nvcc --version?

For a workaround use:

NO_DISTRIBUTED=1 python setup.py install
1 Like

Even I am getting the same error when I run python setup.py install

nvcc --version output :
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
PS : NO_DISTRIBUTED=1 python setup.py install is working but my question is what is NO_DISTRIBUTED=1 for?

Edit 1: As I previously mentioned, I have installed it via NO_DISTRIBUTED=1 python setup.py install but am unable to user affine_grid function.

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

Im having same problem, how we can solve the real problem of gloo library development files?

I guess something related to https://code.ihub.org.cn/projects/123/repositories/159/file_edit_page?file_name=FindGloo.cmake&path=cmake%2FModules%2FFindGloo.cmake&rev=master (which I downloaded and can compile on my own)

Also I guess this is the library? GitHub - facebookincubator/gloo: Collective communications library with various primitives for multi-machine training.

But the point it is that is inside the third party libs

[ 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....