unable to include cub

Unable to include cub

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

when compiling with nvcc in cuda8

/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

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:

the latest version of cub should be ok.

Are you also including thrust headers?

only these two headers were included.

// 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

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

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:

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

https://github.com/NVlabs/cub

The use of

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

Give guide to install cub library from GitHub @Robert_Crovella

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.