###https://sophon.cn/drive/45.html
##驱动安装
#下载官方SDK 解压进入 scripts 目录下
cd *sdk*/scripts
./install_driver_pcie.sh
#验证 机器插了M张SC5卡,N张SC5+卡 x = M + 3*N – 1
ls /dev/ | grep bm-sophon
###########################
##环境变量 在linux下运行bm-smi,依赖环境变量 TERMINFO
#centos: TERMINFO=/usr/share/terminfo; export TERMINFO
#Ubuntu/debian: TERMINFO=/lib/terminfo; export TERMINFO
cd *sdk*/scripts
./install_lib.sh nntc
source envsetup_pcie.sh
#验证
bm-smi
###########################
#驱动 环境变量目录
cd /root/2.4.0_0523_QA_Rel/bmnnsdk2-bm1684_v2.4.0/scripts
./install_lib.sh nntc
source envsetup_pcie.sh
#测试软件存放目录
cd /root/2.4.0_0523_QA_Rel/bmnnsdk2-bm1684_v2.4.0/bin/x86/
##测试
#PCIE 带宽的测试工具
test_cdma_perf stress 0 3 1000
test_cdma_perf stress 1 3 1000
#D2D 带宽的测试工具
test_gdma_perf chip 0
#GEMM - for gemm test, the parameter order is: loops, M, N, K.
./test_perf 0 int8 gemm 6 1000 2000 3000
#CONV - for conv test, the parameter order is: loops, in, ic, ih, iw, oc, kh, kw, pad_h, pad_w, stride_h, stride_w.
./test_perf 0 int8 conv 6 290 64 20 20 64 11 11 1 1 1 1 1 1
#VPU
#解码
ffmpeg -hwaccel bmcodec -hwaccel_device 0 -i /root/1.mp4 -f null /dev/null
ffmpeg -sophon_idx 0 -i /root/1.mp4 -c:v rawvideo -f null /dev/null
ffmpeg -sophon_idx 0 -i /root/1.mkv -c:v rawvideo -f null /dev/null
#转码
ffmpeg -hwaccel bmcodec -hwaccel_device 0 -c:v h264_bm -i /root/1.mp4 -c:v h265_bm -y /root/1.mkv
ffmpeg -hwaccel bmcodec -hwaccel_device 0 -c:v h264_bm -i meeting_01.mp4 -c:v h265_bm -y /root/1.mkv
##压力测试
#--card_mask : one-hot card id enable, default 0 means all devices on system enable. for example, --devid_mask=0x11 means card0 and card4 enable.
#--time : control the running time(minute) of this, default 1.
#--power_utilization : the card power utilization, default 50.
#--target_power : set card power value, default 0 means not used this flag.
#--help : for help.
#满载
./conv_power_test_host --card_mask=0 --time=10 --power_utilization=100
#caffe_model_int8.tar
##公开模型性能测试,单独下载
bmrt_test --bmodel=bmodel/googlenet.int8.bmodel --compare=0
bmrt_test --bmodel= compilation.bmodel
bmrt_test --bmodel=/root/caffe_model_int8/caffe_int8_batch8/caffe_vgg19/compilation.bmodel
bmrt_test --bmodel=/root/caffe_model_int8/caffe_int8_batch8/caffe_yolov3/compilation.bmodel
bmrt_test --bmodel=/root/caffe_model_int8/caffe_int8_batch8/caffe_googlenet/compilation.bmodel
bmrt_test --bmodel=/root/caffe_model_int8/caffe_int8_batch8/caffe_vgg16/compilation.bmodel
bmrt_test --bmodel=/root/caffe_model_int8/caffe_int8_batch8/caffe_resnet50/compilation.bmodel
bmrt_test --bmodel=/root/caffe_model_int8/caffe_int8_batch8/caffe_alexnet/compilation.bmodel
bmrt_test --bmodel=/root/caffe_model_int8/caffe_int8_batch8/caffe_mobilenet/compilation.bmodel
##docker离线加载镜像
curl https://get.docker.com | sh
systemctl start docker
systemctl enable docker
docker load -i bmnnsdk2-bm1684-ubuntu.docker
sh docker_run_bmnnsdk.sh
cd /workspace/examples/SSD_object/cpp_cv_bmcv_bmrt/
make -f Makefile.pcie
#arm
docker run --network=host --rm -it --device /dev/bmdev-ctl --device /dev/bm-sophon0:/dev/bm-sophon0 --device /dev/bm-sophon1:/dev/bm-sophon1 --device /dev/bm-sophon2:/dev/bm-sophon2 -v /home/bitmain/bmnnsdk2test:/bmnnsdk2test ubuntu /bin/bash
####################