# \#error "Expected GLOO\_USE\_CUDA to be defined"

**URL:** <https://discuss.pytorch.org/t/error-expected-gloo-use-cuda-to-be-defined/5333>\
**Category:** Uncategorized\
**Created:** [July 26, 2017, 4:57pm UTC](https://discuss.pytorch.org/t/error-expected-gloo-use-cuda-to-be-defined/5333 "2017-07-26T16:57:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RIk\_Kumar](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/rik_kumar/32/1105_2.png) [@RIk\_Kumar](https://discuss.pytorch.org/u/RIk_Kumar)\
**Post date:** [July 26, 2017, 4:57pm UTC](https://discuss.pytorch.org/t/error-expected-gloo-use-cuda-to-be-defined/5333/1 "2017-07-26T16:57:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![smth](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/smth/32/13_2.png) [@smth](https://discuss.pytorch.org/u/smth)\
**Post date:** [July 26, 2017, 5:58pm UTC](https://discuss.pytorch.org/t/error-expected-gloo-use-cuda-to-be-defined/5333/2 "2017-07-26T17:58:13Z")

</div>

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:

```auto
NO_DISTRIBUTED=1 python setup.py install

```

---

<div class="post-metadata">

**Author:** ![pvskand](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/p/3be4f8/32.png) [@pvskand](https://discuss.pytorch.org/u/pvskand)\
**Post date:** [August 3, 2017, 1:18pm UTC](https://discuss.pytorch.org/t/error-expected-gloo-use-cuda-to-be-defined/5333/3 "2017-08-03T13:18:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![VioletPeng](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/v/e79b87/32.png) [@VioletPeng](https://discuss.pytorch.org/u/VioletPeng)\
**Post date:** [September 21, 2017, 7:34am UTC](https://discuss.pytorch.org/t/error-expected-gloo-use-cuda-to-be-defined/5333/4 "2017-09-21T07:34:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tyoc213](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tyoc213/32/3843_2.png) [@tyoc213](https://discuss.pytorch.org/u/tyoc213)\
**Post date:** [February 21, 2021, 5:30pm UTC](https://discuss.pytorch.org/t/error-expected-gloo-use-cuda-to-be-defined/5333/5 "2021-02-21T17:30:32Z")

</div>

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](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.](https://github.com/facebookincubator/gloo)

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

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

```
