Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9393161
  • 博文数量: 1747
  • 博客积分: 12961
  • 博客等级: 上将
  • 技术积分: 20060
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-09 11:25
个人简介

偷得浮生半桶水(半日闲), 好记性不如抄下来(烂笔头). 信息爆炸的时代, 学习是一项持续的工作.

文章分类

全部博文(1747)

文章存档

2024年(23)

2023年(26)

2022年(112)

2021年(217)

2020年(157)

2019年(192)

2018年(81)

2017年(78)

2016年(70)

2015年(52)

2014年(40)

2013年(51)

2012年(85)

2011年(45)

2010年(231)

2009年(287)

分类: 其他平台

2022-08-04 09:22:24

使用 yocto project.  bitbake meta-toolchain 得到 /opt/下面的交叉编译. 

source /opt/fsl-wayland/4.0/environment-setup-cortexa53-crypto-fsl-linux 这样得到了 $CC 的环境变量.  这样 makefile 或者直接命令行用 $CC即可使用交叉编译器. 

TensorFlowlite 的编译
1. 用 yocto project.  bitbake imx-image-full  这个要非常非常久的时间. 下载编译需要至少 300GB 空间. 
2. 直接下载 tensorflow-lite-imx, 然后编译得到 .a 或者 .so

 静态编译 . 得到 libtensorflow-lite.a

  1. mkdir build_static
  2. cd build_static

  3. ARMCC_PREFIX=aarch64-fsl-linux-
  4. ARMCC_FLAGS="-funsafe-math-optimizations -mcpu=cortex-a53 -march=armv8-a+crc+crypto -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fsl-wayland/4.0/sysroots/cortexa53-crypto-fsl-linux"
  5. cmake -DCMAKE_C_COMPILER=${ARMCC_PREFIX}gcc \
  6.   -DCMAKE_CXX_COMPILER=${ARMCC_PREFIX}g++ \
  7.   -DCMAKE_C_FLAGS="${ARMCC_FLAGS}" \
  8.   -DCMAKE_CXX_FLAGS="${ARMCC_FLAGS}" \
  9.   -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
  10.   -DCMAKE_SYSTEM_NAME=Linux \
  11.   -DCMAKE_SYSTEM_PROCESSOR=aarch64 \
  12.   ../tensorflow/lite/

  13. 得到 libtensorflow-lite.a

  14. 其中会编译到 label_image 的测试程序. 编译连接为
  15. cd /home/ray/imx8mp/tensorflow-imx/build/examples/label_image

  16. /opt/fsl-wayland/4.0/sysroots/x86_64-fslsdk-linux/usr/bin/cmake -E cmake_link_script CMakeFiles/label_image.dir/link.txt --verbose=1

  17. /opt/fsl-wayland/4.0/sysroots/x86_64-fslsdk-linux/usr/bin/aarch64-fsl-linux/aarch64-fsl-linux-g++ --sysroot=/opt/fsl-wayland/4.0/sysroots/cortexa53-crypto-fsl-linux -O2 -pipe -g -feliminate-unused-debug-types -O3 -DNDEBUG -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now CMakeFiles/label_image.dir/bitmap_helpers.cc.o CMakeFiles/label_image.dir/label_image.cc.o CMakeFiles/label_image.dir/home/ray/imx8mp/tensorflow-imx/tensorflow/core/util/stats_calculator.cc.o CMakeFiles/label_image.dir/__/__/profiling/memory_info.cc.o CMakeFiles/label_image.dir/__/__/profiling/profile_summarizer.cc.o CMakeFiles/label_image.dir/__/__/profiling/profile_summary_formatter.cc.o CMakeFiles/label_image.dir/__/__/profiling/time.cc.o CMakeFiles/label_image.dir/__/__/tools/command_line_flags.cc.o CMakeFiles/label_image.dir/__/__/tools/delegates/default_execution_provider.cc.o CMakeFiles/label_image.dir/__/__/tools/delegates/delegate_provider.cc.o CMakeFiles/label_image.dir/__/__/tools/evaluation/utils.cc.o CMakeFiles/label_image.dir/__/__/tools/tool_params.cc.o CMakeFiles/label_image.dir/__/__/tools/delegates/xnnpack_delegate_provider.cc.o CMakeFiles/label_image.dir/__/__/tools/delegates/external_delegate_provider.cc.o -o label_image ../../libtensorflow-lite.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_internal.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_marshalling.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_reflection.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_config.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_program_name.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_private_handle_accessor.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_commandlineflag.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_commandlineflag_internal.a ../../_deps/abseil-cpp-build/absl/container/libabsl_raw_hash_set.a ../../_deps/abseil-cpp-build/absl/container/libabsl_hashtablez_sampler.a ../../_deps/abseil-cpp-build/absl/base/libabsl_exponential_biased.a ../../_deps/abseil-cpp-build/absl/hash/libabsl_hash.a ../../_deps/abseil-cpp-build/absl/hash/libabsl_city.a ../../_deps/abseil-cpp-build/absl/hash/libabsl_wyhash.a ../../_deps/abseil-cpp-build/absl/status/libabsl_status.a ../../_deps/abseil-cpp-build/absl/strings/libabsl_cord.a ../../_deps/abseil-cpp-build/absl/types/libabsl_bad_optional_access.a ../../_deps/abseil-cpp-build/absl/strings/libabsl_str_format_internal.a ../../_deps/abseil-cpp-build/absl/synchronization/libabsl_synchronization.a ../../_deps/abseil-cpp-build/absl/debugging/libabsl_stacktrace.a ../../_deps/abseil-cpp-build/absl/debugging/libabsl_symbolize.a ../../_deps/abseil-cpp-build/absl/debugging/libabsl_debugging_internal.a ../../_deps/abseil-cpp-build/absl/debugging/libabsl_demangle_internal.a ../../_deps/abseil-cpp-build/absl/synchronization/libabsl_graphcycles_internal.a ../../_deps/abseil-cpp-build/absl/base/libabsl_malloc_internal.a ../../_deps/abseil-cpp-build/absl/time/libabsl_time.a ../../_deps/abseil-cpp-build/absl/strings/libabsl_strings.a ../../_deps/abseil-cpp-build/absl/strings/libabsl_strings_internal.a ../../_deps/abseil-cpp-build/absl/base/libabsl_throw_delegate.a ../../_deps/abseil-cpp-build/absl/base/libabsl_base.a ../../_deps/abseil-cpp-build/absl/base/libabsl_spinlock_wait.a -lrt ../../_deps/abseil-cpp-build/absl/numeric/libabsl_int128.a ../../_deps/abseil-cpp-build/absl/time/libabsl_civil_time.a ../../_deps/abseil-cpp-build/absl/time/libabsl_time_zone.a ../../_deps/abseil-cpp-build/absl/types/libabsl_bad_variant_access.a ../../_deps/abseil-cpp-build/absl/base/libabsl_raw_logging_internal.a ../../_deps/abseil-cpp-build/absl/base/libabsl_log_severity.a ../../_deps/farmhash-build/libfarmhash.a ../../_deps/fft2d-build/libfft2d_fftsg2d.a ../../_deps/fft2d-build/libfft2d_fftsg.a ../../_deps/flatbuffers-build/libflatbuffers.a ../../_deps/ruy-build/ruy/libruy_context_get_ctx.a ../../_deps/ruy-build/ruy/libruy_context.a ../../_deps/ruy-build/ruy/libruy_frontend.a ../../_deps/ruy-build/ruy/libruy_kernel_arm.a ../../_deps/ruy-build/ruy/libruy_kernel_avx.a ../../_deps/ruy-build/ruy/libruy_kernel_avx2_fma.a ../../_deps/ruy-build/ruy/libruy_kernel_avx512.a ../../_deps/ruy-build/ruy/libruy_apply_multiplier.a ../../_deps/ruy-build/ruy/libruy_pack_arm.a ../../_deps/ruy-build/ruy/libruy_pack_avx.a ../../_deps/ruy-build/ruy/libruy_pack_avx2_fma.a ../../_deps/ruy-build/ruy/libruy_pack_avx512.a ../../_deps/ruy-build/ruy/libruy_prepare_packed_matrices.a ../../_deps/ruy-build/ruy/libruy_trmul.a ../../_deps/ruy-build/ruy/libruy_ctx.a ../../_deps/ruy-build/ruy/libruy_allocator.a ../../_deps/ruy-build/ruy/libruy_prepacked_cache.a ../../_deps/ruy-build/ruy/libruy_system_aligned_alloc.a ../../_deps/ruy-build/ruy/libruy_have_built_path_for_avx.a ../../_deps/ruy-build/ruy/libruy_have_built_path_for_avx2_fma.a ../../_deps/ruy-build/ruy/libruy_have_built_path_for_avx512.a ../../_deps/ruy-build/ruy/libruy_thread_pool.a ../../_deps/ruy-build/ruy/libruy_blocking_counter.a ../../_deps/ruy-build/ruy/libruy_wait.a ../../_deps/ruy-build/ruy/libruy_denormal.a ../../_deps/ruy-build/ruy/libruy_block_map.a ../../_deps/ruy-build/ruy/libruy_tune.a ../../_deps/ruy-build/ruy/libruy_cpuinfo.a ../../_deps/ruy-build/ruy/profiler/libruy_profiler_instrumentation.a -pthread -ldl ../../_deps/xnnpack-build/libXNNPACK.a /opt/fsl-wayland/4.0/sysroots/cortexa53-crypto-fsl-linux/usr/lib/libm.so ../../_deps/cpuinfo-build/libcpuinfo.a ../../_deps/clog-build/libclog.a ../../pthreadpool/libpthreadpool.a

点击(此处)折叠或打开

  1. 动态库编译
  2. 修改 tensorflow/lite/CMakefile, 改成 ON
  3. 加个环境变量
  4. TFLITE_BUILD_SHARED_LIB=1 ## 从 tensorflow/lite/CMakefile 中得到的.
  5. 执行静态库编译步骤. 得到 so

  6. 最后label_image 的编译命令为.
  7. cd /home/ray/imx8mp/tensorflow-imx/so_build/tools/benchmark && /opt/fsl-wayland/4.0/sysroots/x86_64-fslsdk-linux/usr/bin/cmake -E cmake_link_script CMakeFiles/benchmark_model.dir/link.txt --verbose=1
    /opt/fsl-wayland/4.0/sysroots/x86_64-fslsdk-linux/usr/bin/aarch64-fsl-linux/aarch64-fsl-linux-g++ --sysroot=/opt/fsl-wayland/4.0/sysroots/cortexa53-crypto-fsl-linux  -O2 -pipe -g -feliminate-unused-debug-types  -O3 -DNDEBUG -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed  -Wl,-z,relro,-z,now CMakeFiles/benchmark_model.dir/benchmark_main.cc.o CMakeFiles/benchmark_model.dir/benchmark_model.cc.o CMakeFiles/benchmark_model.dir/benchmark_tflite_model.cc.o CMakeFiles/benchmark_model.dir/benchmark_utils.cc.o CMakeFiles/benchmark_model.dir/profiling_listener.cc.o CMakeFiles/benchmark_model.dir/home/ray/imx8mp/tensorflow-imx/tensorflow/core/util/stats_calculator.cc.o CMakeFiles/benchmark_model.dir/__/__/kernels/internal/utils/sparsity_format_converter.cc.o CMakeFiles/benchmark_model.dir/__/__/profiling/memory_info.cc.o CMakeFiles/benchmark_model.dir/__/__/profiling/memory_usage_monitor.cc.o CMakeFiles/benchmark_model.dir/__/__/profiling/profile_summarizer.cc.o CMakeFiles/benchmark_model.dir/__/__/profiling/profile_summary_formatter.cc.o CMakeFiles/benchmark_model.dir/__/__/profiling/time.cc.o CMakeFiles/benchmark_model.dir/__/command_line_flags.cc.o CMakeFiles/benchmark_model.dir/__/delegates/default_execution_provider.cc.o CMakeFiles/benchmark_model.dir/__/delegates/delegate_provider.cc.o CMakeFiles/benchmark_model.dir/__/evaluation/utils.cc.o CMakeFiles/benchmark_model.dir/__/tool_params.cc.o CMakeFiles/benchmark_model.dir/benchmark_performance_options.cc.o CMakeFiles/benchmark_model.dir/__/delegates/xnnpack_delegate_provider.cc.o CMakeFiles/benchmark_model.dir/__/delegates/external_delegate_provider.cc.o -o benchmark_model  -Wl,-rpath,/home/ray/imx8mp/tensorflow-imx/so_build ../../libtensorflow-lite.so.2.8.0 ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_internal.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_marshalling.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_reflection.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_config.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_program_name.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_private_handle_accessor.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_commandlineflag.a ../../_deps/abseil-cpp-build/absl/flags/libabsl_flags_commandlineflag_internal.a ../../_deps/abseil-cpp-build/absl/container/libabsl_raw_hash_set.a ../../_deps/abseil-cpp-build/absl/container/libabsl_hashtablez_sampler.a ../../_deps/abseil-cpp-build/absl/base/libabsl_exponential_biased.a ../../_deps/abseil-cpp-build/absl/hash/libabsl_hash.a ../../_deps/abseil-cpp-build/absl/hash/libabsl_city.a ../../_deps/abseil-cpp-build/absl/hash/libabsl_wyhash.a ../../_deps/abseil-cpp-build/absl/status/libabsl_status.a ../../_deps/abseil-cpp-build/absl/strings/libabsl_cord.a ../../_deps/abseil-cpp-build/absl/types/libabsl_bad_optional_access.a ../../_deps/abseil-cpp-build/absl/strings/libabsl_str_format_internal.a ../../_deps/abseil-cpp-build/absl/synchronization/libabsl_synchronization.a ../../_deps/abseil-cpp-build/absl/debugging/libabsl_stacktrace.a ../../_deps/abseil-cpp-build/absl/debugging/libabsl_symbolize.a ../../_deps/abseil-cpp-build/absl/debugging/libabsl_debugging_internal.a ../../_deps/abseil-cpp-build/absl/debugging/libabsl_demangle_internal.a ../../_deps/abseil-cpp-build/absl/synchronization/libabsl_graphcycles_internal.a ../../_deps/abseil-cpp-build/absl/base/libabsl_malloc_internal.a ../../_deps/abseil-cpp-build/absl/time/libabsl_time.a ../../_deps/abseil-cpp-build/absl/strings/libabsl_strings.a ../../_deps/abseil-cpp-build/absl/strings/libabsl_strings_internal.a ../../_deps/abseil-cpp-build/absl/base/libabsl_throw_delegate.a ../../_deps/abseil-cpp-build/absl/base/libabsl_base.a ../../_deps/abseil-cpp-build/absl/base/libabsl_spinlock_wait.a -lrt ../../_deps/abseil-cpp-build/absl/numeric/libabsl_int128.a ../../_deps/abseil-cpp-build/absl/time/libabsl_civil_time.a ../../_deps/abseil-cpp-build/absl/time/libabsl_time_zone.a ../../_deps/abseil-cpp-build/absl/types/libabsl_bad_variant_access.a ../../_deps/abseil-cpp-build/absl/base/libabsl_raw_logging_internal.a ../../_deps/abseil-cpp-build/absl/base/libabsl_log_severity.a ../../_deps/farmhash-build/libfarmhash.a ../../_deps/fft2d-build/libfft2d_fftsg2d.a ../../_deps/fft2d-build/libfft2d_fftsg.a ../../_deps/flatbuffers-build/libflatbuffers.a ../../_deps/ruy-build/ruy/libruy_context_get_ctx.a ../../_deps/ruy-build/ruy/libruy_context.a ../../_deps/ruy-build/ruy/libruy_frontend.a ../../_deps/ruy-build/ruy/libruy_kernel_arm.a ../../_deps/ruy-build/ruy/libruy_kernel_avx.a ../../_deps/ruy-build/ruy/libruy_kernel_avx2_fma.a ../../_deps/ruy-build/ruy/libruy_kernel_avx512.a ../../_deps/ruy-build/ruy/libruy_apply_multiplier.a ../../_deps/ruy-build/ruy/libruy_pack_arm.a ../../_deps/ruy-build/ruy/libruy_pack_avx.a ../../_deps/ruy-build/ruy/libruy_pack_avx2_fma.a ../../_deps/ruy-build/ruy/libruy_pack_avx512.a ../../_deps/ruy-build/ruy/libruy_prepare_packed_matrices.a ../../_deps/ruy-build/ruy/libruy_trmul.a ../../_deps/ruy-build/ruy/libruy_ctx.a ../../_deps/ruy-build/ruy/libruy_allocator.a ../../_deps/ruy-build/ruy/libruy_prepacked_cache.a ../../_deps/ruy-build/ruy/libruy_system_aligned_alloc.a ../../_deps/ruy-build/ruy/libruy_have_built_path_for_avx.a ../../_deps/ruy-build/ruy/libruy_have_built_path_for_avx2_fma.a ../../_deps/ruy-build/ruy/libruy_have_built_path_for_avx512.a ../../_deps/ruy-build/ruy/libruy_thread_pool.a ../../_deps/ruy-build/ruy/libruy_blocking_counter.a ../../_deps/ruy-build/ruy/libruy_wait.a ../../_deps/ruy-build/ruy/libruy_denormal.a ../../_deps/ruy-build/ruy/libruy_block_map.a ../../_deps/ruy-build/ruy/libruy_tune.a ../../_deps/ruy-build/ruy/libruy_cpuinfo.a ../../_deps/ruy-build/ruy/profiler/libruy_profiler_instrumentation.a -pthread -ldl ../../_deps/xnnpack-build/libXNNPACK.a /opt/fsl-wayland/4.0/sysroots/cortexa53-crypto-fsl-linux/usr/lib/libm.so ../../_deps/cpuinfo-build/libcpuinfo.a ../../_deps/clog-build/libclog.a ../../pthreadpool/libpthreadpool.a 






阅读(1943) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~