# unable to include cub

**URL:** <https://forums.developer.nvidia.com/t/unable-to-include-cub/61743>\
**Category:** CUDA Programming and Performance\
**Created:** [May 28, 2018, 4:18pm UTC](https://forums.developer.nvidia.com/t/unable-to-include-cub/61743 "2018-05-28T16:18:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![OnePieceOfDeepLearning](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/onepieceofdeeplearning/32/26116_2.png) [@OnePieceOfDeepLearning](https://forums.developer.nvidia.com/u/OnePieceOfDeepLearning)\
**Post date:** [May 28, 2018, 4:18pm UTC](https://forums.developer.nvidia.com/t/unable-to-include-cub/61743/1 "2018-05-28T16:18:24Z")

</div>

Unable to include cub

```auto
#include <cub/block/block_reduce.cuh>
#include <cub/cub.cuh>

```

when compiling with nvcc in cuda8

```auto
/usr/local/cuda/include/thrust/system/cuda/detail/cub/block/specializations/../../block/block_raking_layout.cuh(112): error: Uninitialized is not a template
/usr/local/cuda/include/thrust/system/cuda/detail/cub/block/specializations/../../block/block_raking_layout.cuh(112): error: not a class or struct name

```

Any idea?

thank you

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [May 29, 2018, 12:03am UTC](https://forums.developer.nvidia.com/t/unable-to-include-cub/61743/2 "2018-05-29T00:03:50Z")

</div>

You don’t mention which version of cub you are using. Make sure to use a version of cub that has been tested with cuda 8. You can discover this from the release notes:

> <https://github.com/NVlabs/cub/blob/1.8.0/CHANGE_LOG.TXT>

the latest version of cub should be ok.

Are you also including thrust headers?

---

<div class="post-metadata">

**Author:** ![OnePieceOfDeepLearning](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/onepieceofdeeplearning/32/26116_2.png) [@OnePieceOfDeepLearning](https://forums.developer.nvidia.com/u/OnePieceOfDeepLearning)\
**Post date:** [May 29, 2018, 1:56am UTC](https://forums.developer.nvidia.com/t/unable-to-include-cub/61743/3 "2018-05-29T01:56:34Z")

</div>

only these two headers were included.

```auto
// test.cu
#include <cub/block/block_reduce.cuh>
#include <cub/cub.cuh>

```

How to check the version of cub? it’s bundled with cuda8.0.

Compiled by

```auto
/usr/local/cuda/bin/nvcc test.cu -I"/usr/local/cuda/include/thrust/system/cuda/detail"

```

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [May 29, 2018, 1:41pm UTC](https://forums.developer.nvidia.com/t/unable-to-include-cub/61743/4 "2018-05-29T13:41:15Z")

</div>

cub is not bundled with CUDA 8.0. It is not bundled with any version of CUDA.

Portions of CUB are contained within the version of thrust that is included with recent versions of CUDA. However this is not a standalone version of CUB that can be used by:

```auto
#include <cub/block/block_reduce.cuh>
#include <cub/cub.cuh>

```

The portions of cub included are only intended to be used via thrust. Not by themselves.

If you want to use cub, you need to install it first.

```auto
https://github.com/NVlabs/cub

```

The use of

```auto
-I"/usr/local/cuda/include/thrust/system/cuda/detail"

```

is not documented anywhere and is not a workable attempt to get access to cub.  
In fact, you should never include something via such a path in thrust. header files at that level of depth/nesting in thrust are not designed to be used directly in user code. User code that attempts to do so may break from one CUDA version to the next, due to changes in thrust implementation.

---

<div class="post-metadata">

**Author:** ![arunblaster789](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@arunblaster789](https://forums.developer.nvidia.com/u/arunblaster789)\
**Post date:** [January 25, 2023, 5:21pm UTC](https://forums.developer.nvidia.com/t/unable-to-include-cub/61743/5 "2023-01-25T17:21:52Z")

</div>

Give guide to install cub library from GitHub @Robert_Crovella

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [February 2, 2023, 4:27am UTC](https://forums.developer.nvidia.com/t/unable-to-include-cub/61743/6 "2023-02-02T04:27:49Z")

</div>

Cub is now included in CUDA toolkit distribution. So it should work natively if you have a recent CUDA toolkit version installed.

For other uses, you only need to git clone the master branch or whatever branch of cub you want to use, from the github repo, and then make sure you include path includes the cub header directory in the cloned materials, before it retrieves anything from the CUDA toolkit. I _don’t_ recommend this for general usage, just use what is shipped with the latest CUDA toolkit.
