Error: unknown type name ‘half’

I ve been trying to just compile my code using gcc and I get the above error.

I try to declare an unused variable as half * but compiler does not find the half type. I include “cuda_fp16.h”. What could give this error?

I also tried nvcc and the error seems to stay.

I don t know what info should I give to be more helpful

Hi @thanasisGiannis

According to the documentation, it is __half instead of half.

For more info: https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH____HALF__MISC.html

Regards,
Leon

I used that too. Nothing changed

Hi,

Could you copy and paste the complete error message?

Regards,
Leon

//ex_eig.c
#include <cuda_fp16.h>

int main(){

__half tmpH;
return 0;

}

// Compilation and Error
/usr/local/cuda-10.2/bin/nvcc examples/ex_eig.c -I/usr/local/cuda-10.2/include -L/usr/local/cuda-10.2/lib64 -lm -lcusolver -lcusparse -lcurand -lcublas -lculibos -lcudart -lpthread -ldl --std=c++11 -arch=sm_60 -o examples/ex_eigs
examples/ex_eig.c: In function ‘main’:
examples/ex_eig.c:76:2: error: unknown type name ‘__half’; did you mean ‘__half_raw’?
__half tmpH;
^~~~~~
__half_raw
Makefile:23: recipe for target ‘examples/ex_eigs’ failed
make: *** [examples/ex_eigs] Error 1

Thank you very much for your time!

It seems that the problem is that I used .c file instead of .cu file. Strange that I cannot use this in .c files.

Thank you for your time!

1 Like