提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
- 前言
- 1.环境准备
- 2. 开发机安装环境
前言
官网文档指引:https://doc.sophgo.com/sdk-docs/v23.03.01/docs_latest_release/docs/SophonSDK_doc/zh/html/common_test/disclaimer.html
写的很好,真的很好,就是太太太太多多多多了。。。。
1.环境准备
算能盒子 se5 16路 芯片BM1684
开发机:ubuntu server 20.04 内存 32G CPU 8核心 硬盘:320G
1.安装docker
官网指引:https://docs.docker.com/engine/install/ubuntu/
官网的指引不全,没有设置开机自启,而且sdk3.0以后 算能官网不提供docker环境了。所以docker其实是非必选项。
安装docker
sudo apt-get install docker.io
更换国内镜像源
首先sudo mkdir /etc/docker文件夹
然后sudo vim /etc/docker/daemon.json
在里面添加如下内容:
sudo vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
重载配置文件、重启docker服务
sudo systemctl daemon-reload
sudo service docker restart
配置开机自启
sudo systemctl enable docker
2.下载开发包sdk:
ref:https://developer.sophgo.com/site/index/material/35/all.html
我下载的是这个,05.01 也出来了,是0612更新的,我下载的时候最新版就是V23.03.01. 下载下来是这个(Release_230301-public.zip) 4.8 GB
安装包要准备两份,一份用于se5的固件升级,一份用于开发机的环境搭建,我的开发机没有芯片卡,所以用的是SOC模式。 一共三种工作模式:PCIe Mode、SoC Mode、arm_pcie Mode
3.刷机
略,照着文档刷机,准备sd卡和读卡器,将2的sdk放到读卡器,按照文档刷机
4.安装开发机环境
之前用的centos7.9 可是官方示例走的都是ubuntu,用起来非常不顺,而且在安装LIBSOPHON时第二步就出错了,所以换了ubuntu20.04系统。尽管它在这里提到可以用其它系统安装。
5.centos 上的报错(ubuntu的可以略过)
我是走的这里的时候报错的
报错的输出也贴出来,之前也有报错,根据报错安装插件就解决了,这个好像是libsophon内部自己的报错,搞不定,为了不浪费时间,又申请了一台ubuntu
2. 开发机安装环境
ref:https://doc.sophgo.com/sdk-docs/v23.03.01/docs_latest_release/docs/SophonSDK_doc/zh/html/sdk_intro/4_install.html#linux
参考3.4.1环境配置-linux
解压SDK压缩包
sudo apt-get install p7zip
sudo apt-get install p7zip-full
7z x Release_<date>-public.zip
cd Release_<date>-public
前两个要安装一下,否则会报错,可能是因为解压大文件吧,反正在centos上是遇到了。
上传的特别慢,耐心等待一下吧
所以干会别的吧,一会儿回来, 公司在bj,张家口的服务器,北京没资源了,唉…穷则战术穿插,没法火力压制啊!!
1.普通用户执行docker命令不用sudo的技巧
将这个普通用户进入docker组啊
# 创建docker用户组,若已有docker组会报错,没关系可忽略
sudo groupadd docker
# 将当前用户加入docker组
sudo gpasswd -a ${USER} docker
# 重启docker服务
sudo service docker restart
# 切换当前会话到新group或重新登录重启X会话
2.再次回到正题,将压缩包解压到tpu-nntc
cd tpu-nntc_<date>_<hash>
mkdir tpu-nntc
tar zxvf tpu-nntc_v<x.y.z>-<hash>-<date>.tar.gz --strip-components=1 -C tpu-nntc
3.创建docker容器并进入Docker
cd tpu-nntc
#如果当前系统没有对应的镜像,会自动从docker hub上下载;此处将tpu-nntc的上一级目录映射到docker内的/workspace目录;这里用了8001到8001端口的映射(使用ufw可视化工具会用到端口号)。
#如果端口已被占用,请根据实际情况更换为其他未占用的端口。
docker run -v $PWD/..:/workspace -p 8001:8001 -it sophgo/tpuc_dev:latest
4.初始化软件环境
cd /workspace/tpu-nntc
source scripts/envsetup.sh
请注意,如果docker stop后重新进入,则需要重新source环境变量。
4.libsophon环境搭建
cd libsophon_<date>_<hash>
# 安装依赖库,只需要执行一次
sudo apt install dkms libncurses5
sudo dpkg -i sophon-*.deb
# 在终端执行如下命令,或者log out再log in当前用户后即可使用bm-smi等命令
source /etc/profile
报错了
user@root:~/software/Release_230301-public/libsophon_20230327_025400$ dpkg --print-architecture
amd64
user@root:~/software/Release_230301-public/libsophon_20230327_025400$ sudo dpkg -i sophon-
sophon-driver_0.4.6_amd64.deb sophon-libsophon_0.4.6_amd64.deb sophon-libsophon-dev_0.4.6_amd64.deb
sophon-driver_0.4.6_arm64.deb sophon-libsophon_0.4.6_arm64.deb sophon-libsophon-dev_0.4.6_arm64.deb
user@root:~/software/Release_230301-public/libsophon_20230327_025400$ sudo dpkg -i sophon-*amd64.deb
(Reading database ... 78848 files and directories currently installed.)
Preparing to unpack sophon-driver_0.4.6_amd64.deb ...
-------- Uninstall Beginning --------
Module: bmsophon
Version: 0.4.6
Kernel: 5.4.0-144-generic (x86_64)
-------------------------------------
Status: Before uninstall, this module version was ACTIVE on this kernel.
bmsophon.ko:
- Uninstallation
- Deleting from: /lib/modules/5.4.0-144-generic/updates/dkms/
- Original module
- No original module was found for this module on this kernel.
- Use the dkms install command to reinstall any previous module version.
depmod...
DKMS: uninstall completed.
------------------------------
Deleting module version: 0.4.6
completely from the DKMS tree.
------------------------------
Done.
Unpacking sophon-driver (0.4.6) over (0.4.6) ...
Preparing to unpack sophon-libsophon_0.4.6_amd64.deb ...
Unpacking sophon-libsophon (0.4.6) over (0.4.6) ...
Preparing to unpack sophon-libsophon-dev_0.4.6_amd64.deb ...
Unpacking sophon-libsophon-dev (0.4.6) over (0.4.6) ...
Setting up sophon-driver (0.4.6) ...
Creating symlink /var/lib/dkms/bmsophon/0.4.6/source ->
/usr/src/bmsophon-0.4.6
DKMS: add completed.
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area...
make -j8 KERNELRELEASE=5.4.0-144-generic SOC_MODE=0 PLATFORM=asic SYNC_API_INT_MODE=1 TARGET_PROJECT=sg_pcie_device FW_SIMPLE=0 PCIE_MODE_ENABLE_CPU=1 -C /lib/modules/5.4.0-144-generic/build M=/var/lib/dkms/bmsophon/0.4.6/build ....
cleaning build area...
DKMS: build completed.
bmsophon.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/5.4.0-144-generic/updates/dkms/
depmod...
DKMS: install completed.
Setting up sophon-libsophon (0.4.6) ...
Setting up sophon-libsophon-dev (0.4.6) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
user@root:~/software/Release_230301-public/libsophon_20230327_025400$ source /etc/profile
user@root:~/software/Release_230301-public/libsophon_20230327_025400$
user@root:~/software/Release_230301-public/libsophon_20230327_025400$
user@root:~/software/Release_230301-public/libsophon_20230327_025400$
user@root:~/software/Release_230301-public/libsophon_20230327_025400$
user@root:~/software/Release_230301-public/libsophon_20230327_025400$ bm-smi
get devcount failed!
no sophon device found on this PC or Server
: No such file or directory
user@root:~/software/Release_230301-public/libsophon_20230327_025400$
user@root:~/software/Release_230301-public/libsophon_20230327_025400$ ls /dev/bm*
ls: cannot access '/dev/bm*': No such file or directory
user@root:~/software/Release_230301-public/libsophon_20230327_025400$
user@root:~/software/Release_230301-public/libsophon_20230327_025400$
user@root:~/software/Release_230301-public/libsophon_20230327_025400$
user@root:~/software/Release_230301-public/libsophon_20230327_025400$ source /etc/profile
user@root:~/software/Release_230301-public/libsophon_20230327_025400$
user@root:~/software/Release_230301-public/libsophon_20230327_025400$ bm-smi
get devcount failed!
no sophon device found on this PC or Server
: No such file or directory