您的位置:首页 > 科技 > 能源 > 汕头模板开发建站_电商大数据平台建设方案_抖音关键词搜索指数_代写文章接单平台

汕头模板开发建站_电商大数据平台建设方案_抖音关键词搜索指数_代写文章接单平台

2024/12/23 9:52:24 来源:https://blog.csdn.net/qq_32939413/article/details/144454162  浏览:    关键词:汕头模板开发建站_电商大数据平台建设方案_抖音关键词搜索指数_代写文章接单平台
汕头模板开发建站_电商大数据平台建设方案_抖音关键词搜索指数_代写文章接单平台

一个demo,mindspore lite 部署在树莓派4B ubuntu22.04中,为后续操作开个门!
在这里插入图片描述

环境

  • 开发环境:wsl-ubuntu22.04分发版
  • 部署环境:树莓派4B,操作系统为ubuntu22.04
  • mindspore lite版本:mindspore-lite-2.4.1-linux-aarch64.tar.gz
  • demo模型:mnist手写数字识别

步骤

1. 准备交叉编译环境

  • 安装交叉编译器
sudo apt install gcc-aarch64-linux-gnu
# 验证是否安装成功
(base) joke@ShineZhang:~/mindspore_deploy_demo_aarch64$ aarch64-linux-gnu-gcc --version
aarch64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  • 设置交叉编译环境
# file: toolchain.cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)

2. 下载demo并交叉编译

  • 下载
# 有用的话给个star呗
git clone https://gitee.com/Shine_Zhang/mindspore_aarch64_runtime_demo.git
  • 文件结构说明:
.
├── CMakeLists.txt 
├── README.md
├── build.sh # 执行编译
├── main.c
├── model
│   └── mnist.ms # mnist模型文件
└── toolchain.cmake # 编译工具链
  • 模型文件转换:
    MindSpore Lite端侧模型转换

执行交叉编译:

chomd +x build.sh
./build.sh

3. 部署环境配置

  • 准备环境
    编译后目录如下:
.
├── CMakeLists.txt
├── README.md
├── bin
│   └── mindspore_mnist_demo # es
├── build
│   ├── CMakeCache.txt
│   ├── CMakeFiles
│   ├── Makefile
│   ├── bin
│   ├── cmake_install.cmake
│   ├── mindspore-lite-2.4.1-linux-aarch64
│   ├── mindspore-lite-2.4.1-linux-aarch64.tar.gz
│   ├── mindspore_mnist_demo
│   └── mindspore_quick_start_c
├── build.sh
├── include
│   ├── api
│   ├── c_api
│   ├── dataset
│   ├── ir
│   ├── kernel_interface.h
│   ├── mindapi
│   ├── registry
│   ├── schema
│   └── third_party
├── lib
│   ├── libmindspore-lite.so # es
│   ├── libmindspore_glog.so -> /home/mindspore_deploy_demo_aarch64/lib/libmindspore_glog.so.0
│   └── libmindspore_glog.so.0 # es
├── main.c
├── model
│   └── mnist.ms # es
└── toolchain.cmake

将目录中标记es的文件拷贝至要部署的树莓派4B中

  • 配置运行环境

libmindspore-lite.solibmindspore_glog.so.0拷贝至/usr/local/lib


# 编辑~/.bashrc 增加环境变量
vim ~/.bashrc# ~/.bashrc 末尾增加以下内容后保存:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH# 重新加载当前用户的 ~/.bashrc 配置文件
source ~/.bashrc# 检验动态库是否加载成功
joke in ~ λ ldd mindspore_mnist_demolinux-vdso.so.1 (0x0000ffffb580b000)libmindspore-lite.so => /usr/local/lib/libmindspore-lite.so (0x0000ffffb5040000)libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffffb4e90000)/lib/ld-linux-aarch64.so.1 (0x0000ffffb57d2000)libmindspore_glog.so.0 => /usr/local/lib/libmindspore_glog.so.0 (0x0000ffffb4e30000)libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000ffffb4e10000)libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000ffffb4be0000)libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000ffffb4b40000)libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000ffffb4b10000)libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000ffffb4af0000)

4. 执行demo

joke in ~ λ ./mindspore_mnist_demo mnist.ms           
----------------------------------------------------------
Model Inputs (1):Input 0:Name: serving_default_keras_tensor:0Shape: [1, 28, 28]Data Type: 43Data Size: 3136 bytesModel Outputs (1):Output 0:Name: StatefulPartitionedCall_1:0Shape: [-1]Data Type: 43Data Size: 0 bytesEstimated Model Size: 3136 bytes
----------------------------------------------------------
inputs: Tensor 1:
Tensor shape: [1, 28, 28]
outputs: Tensor 1:
Tensor shape: [1, 10]
outputs[1]: -5.782
outputs[2]: 0.069
outputs[3]: 1.802
outputs[4]: -12.207
outputs[5]: -7.331
outputs[6]: -18.879
outputs[7]: 6.847
outputs[8]: -5.083
outputs[9]: -4.575
Predicted digit: 7 # 预测结果为数字 7

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com