URL: https://tools.mindspore.cn/docs/mindspore/mindspore_compile_guide.txt ######## # 说明 # ######## 1. Ascend编译so与mindspore版本对应关系 下载链接: http://59.36.11.51/ascend910_lib/ r0.3 -> 20200527 r0.5 -> 20200627 master -> 20200627 2. ARM容器镜像,不支持在X86 Host上运行;同样X86容器镜像,不支持在ARM Host上运行 3. 下载PR代码: # Example: 以PR-235为例,提交的目标分支为master PR_NUMBER=235 TARGET_BRANCH=master git clone https://gitee.com/mindspore/mindspore.git -b ${TARGET_BRANCH} cd mindspore git fetch https://gitee.com/mindspore/mindspore.git pull/${PR_NUMBER}/head:mr-origin-${PR_NUMBER} git checkout mr-origin-${PR_NUMBER} git pull --rebase origin ${TARGET_BRANCH} ################## # Ascend版本编译 # ################## 1. Ascend + euleros_aarch64版本 (1) 下载容器镜像 docker pull swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_euleros_aarch64:0.0.2 (2) 创建容器 docker rm -f docker_ms docker run -tid --net=host --name=docker_ms --entrypoint "/bin/bash" swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_euleros_aarch64:0.0.2 (3) 进入容器 docker exec -ti docker_ms bash alias ll='ls -la --color=auto' alias ls='ls --color=auto' (4) 下载编译so cd /usr/local sudo wget http://59.36.11.51/ascend910_lib/20200627/euleros_aarch64/ascend_euleros_aarch64.tar.gz sudo tar -zxf ascend_euleros_aarch64.tar.gz sudo rm -f ascend_euleros_aarch64.tar.gz (5) 设置环境变量 export MSLIBS_SERVER=49.4.0.74 export MSLIBS_CACHE_PATH=~/.mslib (6) 编译命令 bash build.sh -e ascend -j16 2. Ascend + euleros_x86版本 (1) 下载容器镜像 docker pull swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_euleros_x86:0.0.2 (2) 创建容器 docker rm -f docker_ms docker run -tid --net=host --name=docker_ms --entrypoint "/bin/bash" swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_euleros_x86:0.0.2 (3) 进入容器 docker exec -ti docker_ms bash alias ll='ls -la --color=auto' alias ls='ls --color=auto' (4) 下载编译so cd /usr/local sudo wget http://59.36.11.51/ascend910_lib/20200627/euleros_x86/ascend_euleros_x86.tar.gz sudo tar -zxf ascend_euleros_x86.tar.gz sudo rm -f ascend_euleros_x86.tar.gz (5) 设置环境变量 export MSLIBS_SERVER=49.4.0.74 export MSLIBS_CACHE_PATH=~/.mslib (6) 编译命令 bash build.sh -e ascend -j16 3. Ascend + ubuntu_aarch64版本 (1) 下载容器镜像 docker pull swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_ubuntu_aarch64:0.0.2 (2) 创建容器 docker rm -f docker_ms docker run -tid --net=host --name=docker_ms --entrypoint "/bin/bash" swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_ubuntu_aarch64:0.0.2 (3) 进入容器 docker exec -ti docker_ms bash alias ll='ls -la --color=auto' alias ls='ls --color=auto' (4) 下载编译so cd /usr/local sudo wget http://59.36.11.51/ascend910_lib/20200627/ubuntu_aarch64/ascend_ubuntu_aarch64.tar.gz sudo tar -zxf ascend_ubuntu_aarch64.tar.gz sudo rm -f ascend_ubuntu_aarch64.tar.gz (5) 设置环境变量 export MSLIBS_SERVER=49.4.0.74 export MSLIBS_CACHE_PATH=~/.mslib (6) 编译命令 bash build.sh -e ascend -j16 4. Ascend + ubuntu_x86版本 (1) 下载容器镜像 docker pull swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_ubuntu_x86:0.0.2 (2) 创建容器 docker rm -f docker_ms docker run -tid --net=host --name=docker_ms --entrypoint "/bin/bash" swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_ubuntu_x86:0.0.2 (3) 进入容器 docker exec -ti docker_ms bash alias ll='ls -la --color=auto' alias ls='ls --color=auto' (4) 下载编译so cd /usr/local sudo wget http://59.36.11.51/ascend910_lib/20200627/ubuntu_x86/ascend_ubuntu_x86.tar.gz sudo tar -zxf ascend_ubuntu_x86.tar.gz sudo rm -f ascend_ubuntu_x86.tar.gz (5) 设置环境变量 export MSLIBS_SERVER=49.4.0.74 export MSLIBS_CACHE_PATH=~/.mslib (6) 编译命令 bash build.sh -e ascend -j16 ############### # GPU版本编译 # ############### 1. GPU + ubuntu x86(cuda-10.1)版本 (1) 下载容器镜像 docker pull swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_ubuntu_x86:0.0.2 (2) 创建容器 docker rm -f docker_ms docker run -tid --net=host --name=docker_ms --entrypoint "/bin/bash" swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_ubuntu_x86:0.0.2 (3) 进入容器 docker exec -ti docker_ms bash alias ll='ls -la --color=auto' alias ls='ls --color=auto' (4) 下载编译so cd /tmp wget https://tools.mindspore.cn/tools/driver/cuda/install_cuda.sh sudo sh install_cuda.sh (5) 设置环境变量 export MSLIBS_SERVER=49.4.0.74 export MSLIBS_CACHE_PATH=~/.mslib (6) 编译命令 bash build.sh -e gpu -V 10.1 -j16 ############### # CPU版本编译 # ############### 1. CPU + ubuntu x86版本 (1) 下载容器镜像 docker pull swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_ubuntu_x86:0.0.2 (2) 创建容器 docker rm -f docker_ms docker run -tid --net=host --name=docker_ms --entrypoint "/bin/bash" swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_ubuntu_x86:0.0.2 (3) 进入容器 docker exec -ti docker_ms bash alias ll='ls -la --color=auto' alias ls='ls --color=auto' (4) 设置环境变量 export MSLIBS_SERVER=49.4.0.74 export MSLIBS_CACHE_PATH=~/.mslib (5) 编译命令 bash build.sh -e cpu -j16 #################### # UT版本编译与运行 # #################### 1. UT编译 (1) 下载容器镜像 docker pull swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_ubuntu_x86:0.0.2 (2) 创建容器 docker rm -f docker_ms docker run -tid --net=host --name=docker_ms --entrypoint "/bin/bash" swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_ubuntu_x86:0.0.2 (3) 进入容器 docker exec -ti docker_ms bash alias ll='ls -la --color=auto' alias ls='ls --color=auto' (4) 设置环境变量 export MSLIBS_SERVER=49.4.0.74 export MSLIBS_CACHE_PATH=~/.mslib (5) 编译命令 bash build.sh -t on -j16 2. UT运行: (1) CPP用例 cd tests/ut/cpp sh runtest.sh (2) Python用例 cd tests/ut/python sh runtest.sh ############ # 静态检查 # ############ 1. 拉起容器 (1) 下载容器镜像 docker pull swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_check:0.0.2 (2) 创建容器 docker rm -f docker_ms docker run -tid --net=host --name=docker_ms --entrypoint "/bin/bash" swr.cn-north-4.myhuaweicloud.com/mindspore/mindspore_check:0.0.2 (3) 进入容器 docker exec -ti docker_ms bash alias ll='ls -la --color=auto' alias ls='ls --color=auto' 2. Clang-format检查 export PATH=/usr/local/clang-format/bin:$PATH (1) 检查 bash -x scripts/check_clang_format.sh -l (2) 格式化 bash -x scripts/format_source_code.sh -l 3. Cppcheck检查 cppcheck --enable=style --xml --inline-suppr --force --xml-version=2 /home/jenkins/mindspore 2> /home/jenkins/cppcheck-style.xml 4. Cpplint检查 cpplint --root=src --extensions=cxx,cu,hh,cpp,hxx,cuh,h++,cc,c,hpp,c++,h --filter=-build/header_guard --quiet --repository=/home/jenkins/mindspore --linelength=120 --recursive /home/jenkins/mindspore > /home/jenkins/cpplint.log 2>&1 5. Pylint检查 (1) 下载配置文件 cd /home/jenkins wget https://tools.mindspore.cn/tools/check/pylint/rules/pylintrc (2) 检查 (find mindspore -iname '*.py')|xargs pylint --rcfile=/home/jenkins/pylintrc -j 2 --output-format=parseable > /home/jenkins/pylint.log 6. Shellcheck检查 find /home/jenkins/mindspore -name '*.sh' -type f|xargs shellcheck --severity=warning --format=tty > /home/jenkins/shellcheck_result.log