facebookarchive / caffe2

Caffe2 is a lightweight, modular, and scalable deep learning framework.
https://caffe2.ai
Apache License 2.0
8.42k stars 1.94k forks source link

compilation fails with "error: class "__half" has no member "x"" #1293

Closed alexge233 closed 7 years ago

alexge233 commented 7 years ago

Hi,

I'm trying to build on Ubuntu 16.04, kernel 4.4.0 using CUDA 9 (I know it is not officially supported). I've done everything to the letter, and I'm only interested in building the shared libraries and nothing else. I invoke:

cmake . -DUSE_NNPACK=OFF -DUSE_LEVELDB=OFF -DUSE_LEVELDB=OFF -DUSE_ROCKSDB=OFF -DUSE_MPI=OFF  -DUSE_LMDB=OFF -DUSE_NNPACK=OFF -DUSE_GLOO=OFF -DUSE_NCCL=OFF -DUSE_OPENMP=OFF -DBUILD_PYTHON=OFF

But when I start building, I get the following errors:

[ 56%] Building NVCC (Device) object caffe2/CMakeFiles/Caffe2_GPU.dir/core/Caffe2_GPU_generated_context_gpu.cu.o
[ 56%] Building NVCC (Device) object caffe2/CMakeFiles/Caffe2_GPU.dir/utils/Caffe2_GPU_generated_math_gpu.cu.o
[ 57%] Building NVCC (Device) object caffe2/CMakeFiles/Caffe2_GPU.dir/operators/Caffe2_GPU_generated_prelu_op.cu.o
[ 57%] Building NVCC (Device) object caffe2/CMakeFiles/Caffe2_GPU.dir/operators/Caffe2_GPU_generated_lp_pool_op.cu.o
[ 57%] Building NVCC (Device) object caffe2/CMakeFiles/Caffe2_GPU.dir/operators/Caffe2_GPU_generated_pool_op.cu.o
[ 57%] Building NVCC (Device) object caffe2/CMakeFiles/Caffe2_GPU.dir/image/Caffe2_GPU_generated_transform_gpu.cu.o
[ 57%] Building NVCC (Device) object caffe2/CMakeFiles/Caffe2_GPU.dir/operators/Caffe2_GPU_generated_cross_entropy_op.cu.o
[ 58%] Building NVCC (Device) object caffe2/CMakeFiles/Caffe2_GPU.dir/operators/Caffe2_GPU_generated_reverse_packed_segs_op.cu.o
/root/robot_platform/3rd_party/caffe2/caffe2/utils/conversions.h(122): error: class "__half" has no member "x"

/root/robot_platform/3rd_party/caffe2/caffe2/utils/conversions.h(125): error: class "__half" has no member "x"

/root/robot_platform/3rd_party/caffe2/caffe2/utils/conversions.h(143): error: class "__half" has no member "x"

/root/robot_platform/3rd_party/caffe2/caffe2/utils/conversions.h(155): error: class "__half" has no member "x"

/root/robot_platform/3rd_party/caffe2/caffe2/utils/conversions.h(122): error: class "__half" has no member "x"

/root/robot_platform/3rd_party/caffe2/caffe2/utils/conversions.h(125): error: class "__half" has no member "x"

/root/robot_platform/3rd_party/caffe2/caffe2/utils/conversions.h(143): error: class "__half" has no member "x"

/root/robot_platform/3rd_party/caffe2/caffe2/utils/conversions.h(155): error: class "__half" has no member "x"

4 errors detected in the compilation of "/tmp/tmpxft_00003196_00000000-6_transform_gpu.cpp1.ii".
CMake Error at Caffe2_GPU_generated_transform_gpu.cu.o.cmake:262 (message):
  Error generating file
  /root/robot_platform/3rd_party/caffe2/caffe2/CMakeFiles/Caffe2_GPU.dir/image/./Caffe2_GPU_generated_transform_gpu.cu.o

caffe2/CMakeFiles/Caffe2_GPU.dir/build.make:851: recipe for target 'caffe2/CMakeFiles/Caffe2_GPU.dir/image/Caffe2_GPU_generated_transform_gpu.cu.o' failed
make[2]: *** [caffe2/CMakeFiles/Caffe2_GPU.dir/image/Caffe2_GPU_generated_transform_gpu.cu.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/root/robot_platform/3rd_party/caffe2/caffe2/utils/math_gpu.cu(183): error: class "__half" has no member "x"

/root/robot_platform/3rd_party/caffe2/caffe2/utils/math_gpu.cu(185): error: class "__half" has no member "x"

/root/robot_platform/3rd_party/caffe2/caffe2/utils/math_gpu.cu(357): error: class "__half" has no member "x"

/root/robot_platform/3rd_party/caffe2/caffe2/utils/math_gpu.cu(359): error: class "__half" has no member "x"

8 errors detected in the compilation of "/tmp/tmpxft_000031ce_00000000-6_math_gpu.cpp1.ii".
CMake Error at Caffe2_GPU_generated_math_gpu.cu.o.cmake:262 (message):
  Error generating file
  /root/robot_platform/3rd_party/caffe2/caffe2/CMakeFiles/Caffe2_GPU.dir/utils/./Caffe2_GPU_generated_math_gpu.cu.o

caffe2/CMakeFiles/Caffe2_GPU.dir/build.make:3888: recipe for target 'caffe2/CMakeFiles/Caffe2_GPU.dir/utils/Caffe2_GPU_generated_math_gpu.cu.o' failed
make[2]: *** [caffe2/CMakeFiles/Caffe2_GPU.dir/utils/Caffe2_GPU_generated_math_gpu.cu.o] Error 1
/root/robot_platform/3rd_party/caffe2/caffe2/operators/lp_pool_op.cu(24): warning: function "caffe2::<unnamed>::cuda_pow(T, T) [with T=double]" was declared but never referenced

/root/robot_platform/3rd_party/caffe2/caffe2/operators/lp_pool_op.cu(33): warning: function "caffe2::<unnamed>::cuda_abs(T) [with T=double]" was declared but never referenced

CMakeFiles/Makefile2:2085: recipe for target 'caffe2/CMakeFiles/Caffe2_GPU.dir/all' failed
make[1]: *** [caffe2/CMakeFiles/Caffe2_GPU.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

I've read on another github repository that this is related to NCCL? Or is it an issue with CUDA 9? If so, I'll downgrade. Many thanks!

Yangqing commented 7 years ago

Ah, I think after updating the dependency libraries, this should have gone away - could you check out master and do git submodule update?

(On my cuda 9 machine it did pass)

buptwangzw commented 7 years ago

I have also this problem. are you fixed?

alexge233 commented 7 years ago

Hi @Yangqing I checked out master followed by a git submodule update and now I get a cmake error complaining about CUDA architecture:

CMake Error at cmake/Cuda.cmake:30 (message):
  Invalid CUDA_ARCH_NAME, supported values: Kepler, Maxwell, Pascal, Volta,
  All.  Got Auto
Call Stack (most recent call first):
  cmake/Cuda.cmake:166 (caffe2_select_nvcc_arch_flags)
  cmake/Dependencies.cmake:305 (include)
  CMakeLists.txt:74 (include)

-- Configuring incomplete, errors occurred!
See also "/root/robot_platform/3rd_party/caffe2/CMakeFiles/CMakeOutput.log".
See also "/root/robot_platform/3rd_party/caffe2/CMakeFiles/CMakeError.log".

I passed in CMake:

 cmake . -DUSE_NNPACK=OFF -DUSE_LEVELDB=OFF -DUSE_LEVELDB=OFF -DUSE_ROCKSDB=OFF -DUSE_MPI=OFF  -DUSE_LMDB=OFF -DUSE_NNPACK=OFF -DUSE_GLOO=OFF -DUSE_NCCL=OFF -DUSE_OPENMP=OFF -DBUILD_PYTHON=OFF -DCUDA_A
RCH_NAME=Pascal

And it silenced this error, but now I'm getting another warning:

Could NOT find CUB (missing:  CUB_INCLUDE_DIR)

However the libraries compiled fine! Many thanks :+1:

lukeyeager commented 7 years ago

If it helps, I use this command multiple times a day:

git submodule sync --recursive && git submodule update --init --recursive