dlunion / tensorRTIntegrate

TensorRT ONNX Plugin、Inference、Compile
464 stars 114 forks source link

请问可以在ubuntu16.04+cuda9.0上运行吗?编译遇到fp16的错误 #19

Closed zxt881108 closed 4 years ago

zxt881108 commented 4 years ago

编译时候遇到如下错误: src/infer/trt_infer.cpp: In member function 'void TRTInfer::Tensor::toFloat()': src/infer/trt_infer.cpp:276:11: error: cannot convert 'TRTInfer::halfloat {aka half}' to 'float' in assignment dst++ = src++; ^ src/infer/trt_infer.cpp: In member function 'void TRTInfer::Tensor::toHalf()': src/infer/trt_infer.cpp:300:11: error: no match for 'operator=' (operand types are 'TRTInfer::halfloat {aka half}' and 'float') dst++ = src++; ^ In file included from lean/cuda-9.0/include/cuda_fp16.h:1967:0, from src/infer/trt_infer.cpp:10: lean/cuda-9.0/include/cuda_fp16.hpp:137:33: note: candidate: half& half::operator=(const half_raw&) __CUDA_HOSTDEVICE half &operator=(const half_raw &hr) { x = hr.x; return *this; } ^ lean/cuda-9.0/include/cuda_fp16.hpp:137:33: note: no known conversion for argument 1 from 'float' to 'const half_raw&' lean/cuda-9.0/include/cuda_fp16.hpp:124:26: note: candidate: half& half::operator=(const half&) struct __CUDA_ALIGN(2) half { ^ lean/cuda-9.0/include/cuda_fp16.hpp:124:26: note: no known conversion for argument 1 from 'float' to 'const __half&' lean/cuda-9.0/include/cuda_fp16.hpp:124:26: note: candidate: half& half::operator=(half&&) lean/cuda-9.0/include/cuda_fp16.hpp:124:26: note: no known conversion for argument 1 from 'float' to 'half&&' src/infer/trt_infer.cpp: In member function 'void TRTInfer::Tensor::setRandom(float, float)': src/infer/trt_infer.cpp:318:12: error: no match for 'operator=' (operand types are 'TRTInfer::halfloat {aka half}' and 'float') *ptr++ = ccutil::randrf(low, high);

hopef commented 4 years ago

你是自己写的编译吗? cu的编译一定要加-gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_61,code=sm_61 这个编译选项,还有cuda9我不知道是否有half支持,你可以查一下文档

zxt881108 commented 4 years ago

后来搞定了,谢谢

205418367 commented 4 years ago

求分享cmake文件,我也想用cmake编译

shopping-tang commented 2 years ago

我遇见了类似的,后来发现是我算力太低了,需要计算能力达到5.3或以上,早在cmake时就报了,抱着试试的心态继续编译,结果,唉。