How to use CuPy's headers in a CUDA file?
See original GitHub issueI must have missed something trivial. I want to use CuPy’s Thrust headers to do some tests, but I am unable to compile even a simple file like this:
//file: do_nothing.cu
#include <cupy/complex.cuh>
__device__ float xxx (const float x) {
return x+1;
}
Compile it with nvcc -Icupy/core/include -c do_nothing.cu
in the root of CuPy source to generate an object file, I got the following errors:
cupy/core/include/cupy/complex/arithmetic.h:258:78: error: ‘float thrust::abs(const thrust::complex<float>&)’ is not declared in ‘thrust’
__device__ inline float abs(const complex<float>& z) {
^
cupy/core/include/cupy/complex/arithmetic.h:262:80: error: ‘double thrust::abs(const thrust::complex<double>&)’ is not declared in ‘thrust’
__device__ inline double abs(const complex<double>& z) {
^
cupy/core/include/cupy/complex/cexp.h:169:91: error: ‘thrust::complex<double> thrust::exp(const thrust::complex<double>&)’ is not declared in ‘thrust’
__device__ inline complex<double> exp(const complex<double>& z) {
^
cupy/core/include/cupy/complex/cexpf.h:149:89: error: ‘thrust::complex<float> thrust::exp(const thrust::complex<float>&)’ is not declared in ‘thrust’
__device__ inline complex<float> exp(const complex<float>& z) {
^
cupy/core/include/cupy/complex/clog.h:192:91: error: ‘thrust::complex<double> thrust::log(const thrust::complex<double>&)’ is not declared in ‘thrust’
__device__ inline complex<double> log(const complex<double>& z) {
^
cupy/core/include/cupy/complex/clogf.h:188:89: error: ‘thrust::complex<float> thrust::log(const thrust::complex<float>&)’ is not declared in ‘thrust’
__device__ inline complex<float> log(const complex<float>& z) {
^
cupy/core/include/cupy/complex/ccosh.h:195:2: error: ‘thrust::complex<double> thrust::cos(const thrust::complex<double>&)’ is not declared in ‘thrust’
const thrust::complex<double>& z) {
^
cupy/core/include/cupy/complex/ccosh.h:201:2: error: ‘thrust::complex<double> thrust::cosh(const thrust::complex<double>&)’ is not declared in ‘thrust’
const thrust::complex<double>& z) {
^
cupy/core/include/cupy/complex/ccoshf.h:126:89: error: ‘thrust::complex<float> thrust::cos(const thrust::complex<float>&)’ is not declared in ‘thrust’
__device__ inline complex<float> cos(const complex<float>& z) {
^
cupy/core/include/cupy/complex/ccoshf.h:131:90: error: ‘thrust::complex<float> thrust::cosh(const thrust::complex<float>&)’ is not declared in ‘thrust’
__device__ inline complex<float> cosh(const complex<float>& z) {
^
cupy/core/include/cupy/complex/csinh.h:183:91: error: ‘thrust::complex<double> thrust::sin(const thrust::complex<double>&)’ is not declared in ‘thrust’
__device__ inline complex<double> sin(const complex<double>& z) {
^
cupy/core/include/cupy/complex/csinh.h:188:92: error: ‘thrust::complex<double> thrust::sinh(const thrust::complex<double>&)’ is not declared in ‘thrust’
__device__ inline complex<double> sinh(const complex<double>& z) {
^
cupy/core/include/cupy/complex/csinhf.h:124:89: error: ‘thrust::complex<float> thrust::sin(const thrust::complex<float>&)’ is not declared in ‘thrust’
__device__ inline complex<float> sin(const complex<float>& z) {
^
cupy/core/include/cupy/complex/csinhf.h:129:90: error: ‘thrust::complex<float> thrust::sinh(const thrust::complex<float>&)’ is not declared in ‘thrust’
__device__ inline complex<float> sinh(const complex<float>& z) {
^
cupy/core/include/cupy/complex/ctanh.h:182:91: error: ‘thrust::complex<double> thrust::tan(const thrust::complex<double>&)’ is not declared in ‘thrust’
__device__ inline complex<double> tan(const complex<double>& z) {
^
cupy/core/include/cupy/complex/ctanhf.h:107:89: error: ‘thrust::complex<float> thrust::tan(const thrust::complex<float>&)’ is not declared in ‘thrust’
__device__ inline complex<float> tan(const complex<float>& z) {
^
cupy/core/include/cupy/complex/csqrt.h:140:92: error: ‘thrust::complex<double> thrust::sqrt(const thrust::complex<double>&)’ is not declared in ‘thrust’
__device__ inline complex<double> sqrt(const complex<double>& z) {
^
cupy/core/include/cupy/complex/csqrtf.h:137:90: error: ‘thrust::complex<float> thrust::sqrt(const thrust::complex<float>&)’ is not declared in ‘thrust’
__device__ inline complex<float> sqrt(const complex<float>& z) {
^
cupy/core/include/cupy/complex/catrig.h:697:92: error: ‘thrust::complex<double> thrust::acos(const thrust::complex<double>&)’ is not declared in ‘thrust’
__device__ inline complex<double> acos(const complex<double>& z) {
^
cupy/core/include/cupy/complex/catrig.h:702:92: error: ‘thrust::complex<double> thrust::asin(const thrust::complex<double>&)’ is not declared in ‘thrust’
__device__ inline complex<double> asin(const complex<double>& z) {
^
cupy/core/include/cupy/complex/catrig.h:708:92: error: ‘thrust::complex<double> thrust::atan(const thrust::complex<double>&)’ is not declared in ‘thrust’
__device__ inline complex<double> atan(const complex<double>& z) {
^
cupy/core/include/cupy/complex/catrig.h:725:93: error: ‘thrust::complex<double> thrust::atanh(const thrust::complex<double>&)’ is not declared in ‘thrust’
__device__ inline complex<double> atanh(const complex<double>& z) {
^
cupy/core/include/cupy/complex/catrigf.h:411:90: error: ‘thrust::complex<float> thrust::acos(const thrust::complex<float>&)’ is not declared in ‘thrust’
__device__ inline complex<float> acos(const complex<float>& z) {
^
cupy/core/include/cupy/complex/catrigf.h:416:90: error: ‘thrust::complex<float> thrust::asin(const thrust::complex<float>&)’ is not declared in ‘thrust’
__device__ inline complex<float> asin(const complex<float>& z) {
^
cupy/core/include/cupy/complex/catrigf.h:422:90: error: ‘thrust::complex<float> thrust::atan(const thrust::complex<float>&)’ is not declared in ‘thrust’
__device__ inline complex<float> atan(const complex<float>& z) {
^
cupy/core/include/cupy/complex/catrigf.h:439:91: error: ‘thrust::complex<float> thrust::atanh(const thrust::complex<float>&)’ is not declared in ‘thrust’
__device__ inline complex<float> atanh(const complex<float>& z) {
^
Any hint or comment is appreciated.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Headers in CUDA C - NVIDIA Developer Forums
Hello, Suppose I want to write somewhat larger kernels in CUDA C… do I still need to use header files to split up...
Read more >Compiling a CUDA file, C file, and Cuda header file
Use nvcc -c to compile all CUDA-files and gcc -c to compile C-files. After that simply link them by gcc. I recommend you...
Read more >Building CUDA Code - CERN Indico
By convention CUDA code is put into the following types of files. • *.cuh: Header files that require CUDA in “some way”.
Read more >D94337 Add cuda header type for cuh files - LLVM
This adds a cuda header type with file extension "cuh". The output type file extension is "cuhi" - not sure if this is...
Read more >CUDA Crash Course (v2): Visual Studio 2019 Setup - YouTube
In this video we look at the basic setup for CUDA development with VIsual Studio 2019!
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had this same compiler issue yesterday while trying to compile the latest CuPy master branch on a RHEL 7 machine. RHEL 7’s EOL is 2024, i.e. there’s probably still a good number of people using it, but its default gcc version is 4.8.5, which won’t compile CuPy successfully.
I think it’d be good if you mentioned this on the installation doc page, so people are aware of the issue? If it helps, here’s what I used to point pip and nvcc to the latest dev version gcc binaries on that particular machine:
@MrArsGravis Yes, I think this is planned: #3530. In this sense, CUDA’s installation guide for Linux is inaccurate. It mentioned gcc 4.8.5 is supported on several distros until CUDA 11.0, which now has a footnote to address this issue:
But this C++11 incompatibility already happened long before CUDA 11…