Source compile error related to half precision?

pytorch worked fine when I installed with either anaconda or pip.
However, when I tried to build pytorch from the source (python install), I got the following error messages. (I am using python 2.7.13, gcc 4.8.5, cuda 8.0)

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/homes/3/kimjook/pytorch -I/homes/3/kimjook/pytorch/torch/csrc -I/homes/3/kimjook/pytorch/torch/lib/tmp_install/include -I/homes/3/kimjook/pytorch/torch/lib/tmp_install/include/TH -I/homes/3/kimjook/pytorch/torch/lib/tmp_install/include/THPP -I/homes/3/kimjook/pytorch/torch/lib/tmp_install/include/THNN -I/u/drspeech/opt/anaconda2/lib/python2.7/site-packages/numpy/core/include -I/usr/local/cuda/include -I/homes/3/kimjook/pytorch/torch/lib/tmp_install/include/THCUNN -I/u/drspeech/opt/anaconda2/include/python2.7 -c torch/csrc/cuda/Storage.cpp -o build/temp.linux-x86_64-2.7/torch/csrc/cuda/Storage.o -D_THP_CORE -std=c++11 -Wno-write-strings -DWITH_NUMPY -DWITH_CUDA -DCUDA_LIB_PATH=/usr/local/cuda/lib64
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
torch/csrc/nn/THNN_generic.cpp: In function ‘void torch::nn::Abs_updateOutput(thpp::Tensor*, thpp::Tensor*)’:
torch/csrc/nn/THNN_generic.cpp:45:14: error: ‘THCudaHalfTensor’ was not declared in this scope

In file included from /homes/3/kimjook/pytorch/torch/lib/tmp_install/include/THPP/tensors/../storages/THCStorage.hpp:11:0,
                 from /homes/3/kimjook/pytorch/torch/lib/tmp_install/include/THPP/tensors/THCTensor.hpp:22,
                 from torch/csrc/DynamicTypes.cpp:11:
/homes/3/kimjook/pytorch/torch/lib/tmp_install/include/THPP/tensors/../storages/../TraitsCuda.hpp:9:20: error: ‘half’ was not declared in this scope
 struct type_traits<half> {

It seems that the compiler cannot correctly recognize “half” precision related data structures or classes. How would I reslove this problem? (I don’t need half precision operations so if possible it’s fine for me to disable it.)


That’s weird. Could you please clean the install (watch out, if you have any uncommited changes it will delete them!!) git clean -xfd and then run python install and upload the full log to pastebin?

The full log is as follows.


i’ve looked at the log and I cant really see what the problem is :frowning:

are you using CUDA 8.0.27 by any chance, instead of the latest 8.0.44?

I am using CUDA 8.0.61. Thanks.

I have no idea what’s wrong. You have a fresh version of CUDA, so half should be automatically enabled everywhere.

Can you check if adding #include <cuda.h> after this line helps?

Tried it, but no differences.

Ok, are you sure that /usr/local/cuda-8.0 and /usr/local/cuda contain the same CUDA version? I’m pretty sure there’s something wrong with that. All librs are compiled with /usr/local/cuda-8.0 and claim to detect FP16, but not when the extension is compiled.

Another hack would be to add -DCUDA_HAS_FP16=1 here.

Oh. That’s it. My system’s /usr/local/cuda is linked to cuda-6.5 since I am sharing the system with others.

I am using CUDA 8 by setting
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/cuda-8.0/bin:$LD_PATH

Would there be any other way I can explictly specify the directory path?


Great! You could use CUDA_HOME env variable.