4 Star 7 Fork 6

CANN / cann-halo

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
Clone or Download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.en.md

ODLA Integrate Ascend Manual

Environment

Device Environment

Atlas300I(3000) Server,Memory larger than 16G,root disk remaining space larger than 64G; Install the latest driver and firmware follow 《User Manual》

Software Environment

gcc/g++: gcc/g++ version of server later than 7.5.0

docker:Install docker at server

Docker configuration

1.Download ODLA docer image as root(note: all command of this readme are execute as root).Follow ODLA environment preparation readme pull CPU docker image:

docker pull registry-intl.us-west-1.aliyuncs.com/computation/halo:latest-devel-x86_64-ubuntu18.04

2.Modify ODLA image start script start_docker_cpu.sh to add Atlas300I driver mapping,change

ID=`docker run $docker_run_flag --privileged --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -t -d --name $CONTAINER_NAME -v $MOUNT_DIR:/host  --tmpfs /tmp:exec --rm $IMAGE `

to

ID=`docker run $docker_run_flag --privileged --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --net=host -t -d --name $CONTAINER_NAME --cap-add LINUX_IMMUTABLE --device=/dev/davinci0 --device=/dev/davinci_manager --device=/dev/devmm_svm --device=/dev/hisi_hdc -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi -v /usr/local/Ascend/driver/:/usr/local/Ascend/driver -v $MOUNT_DIR:/host  --tmpfs /tmp:exec $IMAGE `

3.Exectue the script to start docker container

4.Install python3.7.5 by resource code in the docker container。Follow 《安装Python3.7.5(Ubuntu)》install dependency, compile, install and set environment variable

5.Add user HwHiAiUser in docker container:

(1) Execute command in host server

id HwHiAiUser

to get user gid of HwHiAiUser in host

(2) Create user HwHiAiUser in docker container

groupadd -g <gid> HwHiAiUser && useradd -g HwHiAiUser -d /home/HwHiAiUser -m HwHiAiUser && echo ok

Replace gid with the value get in (1)

6.Copy /etc/ascend_install.info in host to docker container /etc/ directory

7.Install Atlas300I latest CANN package。Download latest commercial or community edition,follow 《Environment manual》 install cann ascend-toolkit

Halo Integrate Ascend

1.Follow ODLA readme download halo repository

git clone https://github.com/alibaba/heterogeneity-aware-lowering-and-optimization.git --recurse-submodules -j8

2.Download halo ascend code

git clone https://gitee.com/cann/cann-halo.git

3.Copy cann-halo/ascend to heterogeneity-aware-lowering-and-optimization/ODLA/platforms/

4.Modify heterogeneity-aware-lowering-and-optimization/ODLA/platforms/CMakeLists.txt, add

option(ODLA_BUILD_ASCEND "Build ODLA Runtime Library for ASCEND" ON)
if (ODLA_BUILD_ASCEND)
  add_subdirectory(ascend)
endif()

5.Create build directory in heterogeneity-aware-lowering-and-optimization/ directory and compile halo

source /usr/local/Ascend/ascend-toolkit/set_env.sh

mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DODLA_BUILD_TRT=NO -G Ninja ..
ninja 

HALO_ROOT is the halo code directory,you should set it accord your on reality。If generate libodla_ascend.so in directory build/lib,it means integrate success.

Resnet50_v2 demo integrate Ascend

Integrate ascend to halo odla need modify:

1.Add ascend entry to resnet50_v2 demo entry script

if [[ $TEST_WITH_ASCEND -eq 1 ]]; then
  echo "======== Testing with ODLA Ascend ========"
  python3 $curr_dir/../../invoke_halo.py --model $model_file --label-file \
          $curr_dir/../1000_labels.txt --image-dir $image_dir \
          --odla ascend | tee $2
fi

2.When generate odla model files by halo in invoke_halo.py,the weights must be resource code,so add --emit-data-as-c option when execute halo, likely:

halo --emit-data-as-c -target cxx resnet50-v2-7.onnx -o resnet50_v2_model.cc

3.When compile model file by g++, ascend include file search path, share library search path and dependency library:

(1)ascend include path

/usr/local/Ascend/ascend-toolkit/latest/opp/op_proto/built-in/inc 
/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/include 

(2)ascend share library path

/usr/local/Ascend/ascend-toolkit/latest/opp/op_impl/built-in/ai_core/tbe/op_tiling/ 
/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/lib64/plugin/opskernel/ 
/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/lib64/stub/

(3)dependency ascend share library: libgraph.so, libge_runner.so, libascendcl.so, libfe.so和liboptiling.so

4.When execute demo, ascend share load path:

/usr/local/Ascend/driver/lib64
/usr/local/Ascend/driver/lib64/common
/usr/local/Ascend/driver/lib64/driver
/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/lib64
/usr/local/Ascend/ascend-toolkit/latest/atc/lib64

We can execute command below to config environment:

source /usr/local/Ascend/ascend-toolkit/set_env.sh
export PYTHONWARNINGS='ignore:semaphore_tracker:UserWarning' 

About

HALO/ODLA通过CANN的开放接口使能Ascend的Adapter Sample expand collapse
C++ and 3 more languages
Apache-2.0
Cancel

Releases

No release

cann-halo

Contributors

All

Activities

Load More
can not load any more
C++
1
https://toscode.gitee.com/cann/cann-halo.git
git@toscode.gitee.com:cann/cann-halo.git
cann
cann-halo
cann-halo
master

Search

101014 b92fc32e 1850385 101014 af024cb7 1850385