N430x盒子和一体机默认都安装了OpenEuler 24.03 LTS,默认安装并使能了Docker。不过由于不同的N430x设置硬盘配置不太一样,有的安装了nvme固态硬盘,有的安装了sata固态硬盘、有的安装了机械硬盘,有的只有eMMC,所以为了达到最佳性能,需要将Docker目录设置到硬盘或者eMMC的特定分区上。
硬盘分区与格式化会丢失所有硬盘数据,请提前备份好数据!!!
sudo fdisk -l
从结果中查找/dev/sda
/dev/sdb
/dev/nvme
/dev/nvme0n1
等关键信息,如果有其中的任何一个,说明有磁盘,不过U盘等也是/dev/sda
/dev/sdb
这种名字,确认是如果插了U盘,需要将U盘排除掉。
输出例子:
[root@openEuler ~]# fdisk -l
Disk /dev/mtdblock0: 128 KiB, 131072 bytes, 256 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
# 这个是nvme固态硬盘
Disk /dev/nvme0n1: 1.86 TiB, 2048408248320 bytes, 4000797360 sectors
Disk model: BIWIN TD80G2T230S2T
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mtdblock1: 128 KiB, 131072 bytes, 256 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mmcblk0: 58.25 GiB, 62545461248 bytes, 122159104 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: D134EFF6-BF70-2C1C-2975-C99EB001F770
Device Start End Sectors Size Type
/dev/mmcblk0p1 2048 6143 4096 2M Linux filesystem
/dev/mmcblk0p2 6144 415743 409600 200M Linux filesystem
/dev/mmcblk0p3 415744 419839 4096 2M Linux filesystem
/dev/mmcblk0p4 419840 423935 4096 2M Linux filesystem
/dev/mmcblk0p5 423936 833535 409600 200M Linux filesystem
/dev/mmcblk0p6 833536 1243135 409600 200M Linux filesystem
/dev/mmcblk0p7 1243136 13826047 12582912 6G Linux filesystem
/dev/mmcblk0p8 13826048 28506111 14680064 7G Linux filesystem
/dev/mmcblk0p9 28506112 122159070 93652959 44.7G Linux filesystem
如果有硬盘则进行接下来的步骤,如果没有硬盘,则无需进行接下来的步骤,直接跳到第二章。
如果对硬盘有特殊分区需求,则可以对硬盘进行分区操作,一般新买的硬盘或则设备自带的硬盘已经做了分区操作,此处只针对有特殊要求的使用者。
硬盘分区操作步骤如下(以nvme为例):
[root@openEuler ~]# gdisk /dev/nvme0n1 #也可能是 /dev/sdb 或者 /dev/nvme0n1,具体看1.1的结果
GPT fdisk (gdisk) version 1.0.9
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries in memory. # 创建一个新的GPT分区表:
Warning! Unable to generate a proper UUID! Creating an improper one as a last
resort! Windows 7 may crash if you save this partition table!
Command (? for help):
输入n创建新的分区,如果只需要创建一个分区,后面几个就使用默认参数,直接回车即可:
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-4000797326, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-4000797326, default = 4000796671) or {+-}size{KMGTP}:
Warning! Unable to generate a proper UUID! Creating an improper one as a last
resort! Windows 7 may crash if you save this partition table!
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
Command (? for help):
使用命令w保持分区信息,并使用y确认:
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/nvme0n1.
The operation has completed successfully.
至此硬盘分区就完成了。
硬盘分区后,需要在分区上创建文件系统,一般使用ext4文件系统,如果想使用别的文件系统类型也可以。
sudo mkfs.ext4 /dev/nvme0n1
[root@openEuler ~]# sudo mkfs.ext4 /dev/nvme0n1
mke2fs 1.47.0 (5-Feb-2023)
Found a gpt partition table in /dev/nvme0n1
Proceed anyway? (y,N) y # 此处需要输入y确认
Discarding device blocks: done
Creating filesystem with 500099670 4k blocks and 125026304 inodes
Filesystem UUID: da56d4c7-fa0f-4b0c-b14d-2388f6988031
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
创建挂载点(这里假设磁盘挂载到/bigdata/目录):
sudo mkdir -p /bigdata
修改配置文件/etc/fstab,新增需要自动挂载的磁盘分区:
sudo vim /etc/fstab
以上面nvme的例子,新增如下行到配置文件末尾,保存并退出:
/dev/nvme0n1 /bigdata ext4 defaults 0 1
测试挂载:
sudo mount -a
使用lsblk命令验证是否挂载:
[root@openEuler ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
mtdblock0 31:0 0 128K 0 disk
mtdblock1 31:1 0 128K 0 disk
mmcblk0 179:0 0 58.3G 0 disk
├─mmcblk0p1 179:1 0 2M 0 part
├─mmcblk0p2 179:2 0 200M 0 part
├─mmcblk0p3 179:3 0 2M 0 part
├─mmcblk0p4 179:4 0 2M 0 part
├─mmcblk0p5 179:5 0 200M 0 part
├─mmcblk0p6 179:6 0 200M 0 part
├─mmcblk0p7 179:7 0 6G 0 part /mnt/rootfs.ro
├─mmcblk0p8 179:8 0 7G 0 part /mnt/rootfs.rw
└─mmcblk0p9 179:9 0 44.7G 0 part /data
mmcblk0boot0 179:32 0 4M 1 disk
mmcblk0boot1 179:64 0 4M 1 disk
nvme0n1 259:0 0 1.9T 0 disk /bigdata # 此处有/bigdata说明已经正常挂载
sudo systemctl stop docker
sudo systemctl stop docker.socket
sudo systemctl stop containerd
# 有硬盘的话在硬盘上创建目录
sudo mkdir -p /bigdata/docker
# 没有硬盘的话在eMMC上创建目录,mmcblk0p9默认挂载在/data/分区
sudo mkdir -p /data/docker
# sudo ln -s /data /bigdata
/etc/docker/daemon.json
, 如果该配置文件不存在,则使用下面的命令创建配置文件sudo vim /etc/docker/daemon.json
将下面的内容增加到配置文件中并保存:
硬盘使用下面的配置:
{
"data-root": "/bigdata/docker"
}
没有硬盘使用下面的配置:
{
"data-root": "/data/docker"
}
sudo systemctl start docker
docker info -f '{{ .DockerRootDir}}'
[root@openEuler ~]# docker info -f '{{ .DockerRootDir}}'
/bigdata/docker #是我们前面配置的目录,说明已经生效
[root@openEuler ~]#
# 下载rbaisdk最新版
cd /data/
wget https://rbbsp.oss-cn-shenzhen.aliyuncs.com/docker_images/corerain_rbaisdk_v2.2.0_8ad600e112c1.tar.xz
# 导入镜像
docker load -i corerain_rbaisdk_v2.2.0_8ad600e112c1.tar.xz
# 创建容器
docker create --name rbaisdk-v2.2.0 --ipc=host --net=host --privileged=true \
-v /etc/localtime:/etc/localtime:ro \
-v /sys/kernel/debug/:/sys/kernel/debug/ \
-v /opt/rb/run/:/opt/rb/run/ \
-v /root/workspace/:/workspace/ \
-it corerain/rbaisdk:v2.2.0
# 启动容器
docker start rbaisdk-v2.2.0
# 检查容器日志
[root@openEuler ~]# docker logs rbaisdk-v2.2.0
rt_api_server is not running. restarting...
Product: N430UW with ID 8.
Product: N430UW with ID 8.
Core should be running...
Core should be running...
Core should be running...
Core should be running...
Server listening on 0.0.0.0:10088
# 启动容器中的bash并运行、调试自己的应用
docker exec -it rbaisdk-v2.2.0 /bin/bash
# 将demo编译出来的out目录拷贝到设备上的某个目录
# 拷贝out到容器内部
docker cp out rbaisdk-v2.2.0:/root
# 启动容器中的bash并运行demo
docker exec -it rbaisdk-v2.2.0 /bin/bash
# 在容器中运行demo
cd /root/out/resnet50_cpp
bash-5.2# ./resnet50_cpp
Product: N430UW with ID 8.
Product: N430UW with ID 8.
> input shape: 1
> input shape: 224
> input shape: 224
> input shape: 3
inference finished.
top1 : 701
out s :1
out s : 1000
out s : 1
out s : 1
finished.