zhy520xp / mace-makefile-project

makefile 交叉编译 libmace.a,并能在嵌入式端调用GPU来跑深度学习模型
95 stars 18 forks source link

GPU Demo编译不过: undefined reference to `mace::kTuningParamsData' #1

Closed bluelml closed 6 years ago

bluelml commented 6 years ago

Hardware: RK3399 OS: ubuntu

aarch64-linux-gnu-g++ -std=c++11 -I../include/ -I../include/mace -I../include/protobuf3.4.0 -O3 -o unit_test.o -c unit_test.cpp CXX = aarch64-linux-gnu-g++ unit_test.cpp: In function ‘int main(int, char*)’: unit_test.cpp:104:144: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘__time_t {aka long int}’ [-Wformat=] printf("=====>>>>>Warm up Run Model spend time:%d ms\n",(tm_after.tv_sec -tm_before.tv_sec)1000 + (tm_after.tv_usec - tm_before.tv_usec)/1000); ^ unit_test.cpp:111:144: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘__time_t {aka long int}’ [-Wformat=] printf("=====>>>>>Normal Run Model spend time:%d ms\n",(tm_after.tv_sec -tm_before.tv_sec)*1000 + (tm_after.tv_usec - tm_before.tv_usec)/1000); ^ aarch64-linux-gnu-g++ -o demo unit_test.o ../library/mace_gpu/libmace.a ../library/protobuf3.4.0/libprotobuf-lite.a -fopenmp -lm -pthread -lrt -ldl ../library/mace_gpu/libmace.a(opencl_runtime.o): In function mace::OpenCLRuntime::OpenCLRuntime()': opencl_runtime.cc:(.text+0x6e0c): undefined reference tomace::kTuningParamsData' opencl_runtime.cc:(.text+0x6e10): undefined reference to mace::kTuningParamsData' opencl_runtime.cc:(.text+0x6e20): undefined reference tomace::kTuningParamsData' opencl_runtime.cc:(.text+0x6e24): undefined reference to mace::kTuningParamsData' opencl_runtime.cc:(.text+0x7028): undefined reference tomace::kTuningParamsData' ../library/mace_gpu/libmace.a(opencl_runtime.o):opencl_runtime.cc:(.text+0x702c): more undefined references to `mace::kTuningParamsData' follow collect2: error: ld returned 1 exit status Makefile:29: recipe for target 'demo' failed make: *** [demo] Error 1

zhy520xp commented 6 years ago

你好这个问题我看到了,应该是我少传了某个源文件导致的。明天我去把它补上,谢谢。

zhy520xp commented 6 years ago

老铁这个问题的原因找到了。kTuningParamsData这个map是在mace/codegen/tuning/tuning_params.cc中定义。 extern const std::map<std::string, std::vector> kTuningParamsData = {

}; 它这种为map赋值的特性,在海思3559A的编译链上是支持的,在你那个编译链是不支持的。 所以你需要修改mace/Makefile中 ifeq ($(PLATFORM),GPU) CPPFLAGS := -std=c++11 -DMACE_ENABLE_OPENCL endif 改为-std=c++14。 如果3399编译链不支持c++14的话,则将mace/utils/turnr.h中 inline void ReadRunParamters() {

} 就行了。

zhy520xp commented 6 years ago

这个kTuningParamsData参数是将网络模型转换为GPU权重时,tuning的配置参数。我这个工程在转换的时候没有用tuning,而这个参数的定义文件是自动生成代码,所以这个参数被赋值为空值(mace/gencode下的文件全是在模型build时自动生成的)。

bluelml commented 6 years ago

按照你的第二种方法,删除函数内容 后编译通过,多谢!

zhy520xp commented 6 years ago

能否把rk3399运行的结果截屏给我看看,加一下qq958499851

liupengkd commented 6 years ago

@bluelml 你的rk3399的GPU的libOpenCL.so和libmali.so是自己用opencl交叉编译的吗?可以发我一份吗?邮箱1374294826@qq.com

feixuedudiao commented 5 years ago

按照你的第二种方法,删除函数内容 后编译通过,多谢! 你的第二种方法指的是啥,没有搞明白。你具体是删除哪个函数内容的。