ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

CANN/ge 源码构建指南

CANN/ge 源码构建指南 Source Code Build【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge1. Environment PreparationBefore source code compilation, please complete basic environment setup first. For specific operations, please refer to Quick Installation.2. Environment VerificationAfter installing CANN package, you need to verify whether the environment is normal.# View version information provided by CANN Toolkits version field (default path installation), arch represents CPU architecture (aarch64 or x86_64). In WebIDE scenario, please replace /usr/local with /home/developer. cat /usr/local/Ascend/cann/arch-linux/ascend_toolkit_install.info # View version information provided by CANN ops version field (default path installation), opsname represents the name of the ops sub-package to be queried, please replace according to actual installation path. In WebIDE scenario, please replace /usr/local with /home/developer. cat /usr/local/Ascend/cann/arch-linux/ascend_ops_install.info3. Environment Variable ConfigurationChoose appropriate commands according to actual scenarios:# Default path installation, taking root user as example (for non-root users, replace /usr/local with ${HOME}) source /usr/local/Ascend/cann/set_env.sh # Specified path installation source ${install_path}/cann/set_env.sh4. Source Code Compilation4.1 Download Source CodeDevelopers can download the source code of this repository through the following commands:# Download project source code, taking master branch as example git clone https://gitcode.com/cann/ge.git4.2 Install DependenciesInstall DependenciesThe following lists the dependencies used for GE source code compilation, please note version requirements (if you encounter installation issues, please try switching mirror sources).[!NOTE] Note If using mirror mode for project experience, all dependencies are already included in init_env.sh, you can skip this install dependencies step.GCC 7.3.xPython3 3.9.xIn addition to Python dependencies required by CANN development suite package, you also need to install coverage additionally and add Python3s bin path to PATH environment variable. Command example is as follows:pip3 install coverage # Modify PYTHON3_HOME below to actual Python installation directory export PATH$PATH:$PYTHON3_HOME/binCMake 3.16.0 (version 3.20.0 recommended)bash 5.1.16ccache/asan/autoconf/automake/libtool/gperf/lcov/libasan/patch/perl/graph-easy (graph-easy is optional)# Ubuntu operating system installation command example as follows, other operating system dependencies may have some differences, please install yourself # asan taking gcc 7.5.0 version as example, libasan4 is installed, for other versions please install corresponding version asan sudo apt-get update sudo apt-get install cmake ccache bash lcov libasan4 autoconf automake libtool gperf libgraph-easy-perl patch perlInstall other Python dependencies## Enter project source code root directory, execute installation command cd ge pip3 install -r requirements.txtCheck Compilation EnvironmentAfter installation is complete, its recommended to execute the environment check script to confirm whether the current environment meets compilation requirements.bash scripts/check_env.shCheck result explanation is as follows:StatusMeaningHandling Suggestion[PASS]Check passedNo action needed[WARNING]Non-critical dependency missing or version deviationSuggest fixing, does not affect core compilation[ERROR]Critical dependency missing or version incompatibleMust fix, otherwise cannot compile[!NOTE] Note All check items and version constraints in the environment check script strictly come from docs/build.md and requirements.txt. If documents and dependencies are updated, please synchronize modification to script.4.3 Compilation[!NOTE] Note If your compilation environment cannot access the network, since source code cannot be downloaded throughgitcommand, you need to download source code and third-party library dependencies in a networked environment, then manually upload to target environment. Please refer to Offline Compilation Guide. If your compilation environment can access the network, after downloading source code throughgitcommand, open source third-party software will be automatically downloaded during compilation process.If your compilation environment can access the network, or has completed Offline Compilation Guide,GEprovides one-click compilation capability. Enter the code repository root directory and compile through the following command:bash build.sh --pkg_type--pkg_type (optional): Represents sub-package type, values includege_compiler,ge_executoranddflow. Different compilation parameters compile different sub-packages. If not set, all three sub-packages will be compiled simultaneously.More compilation parameters can be viewed throughbash build.sh -h. After successful compilation,cann-component_version_arch.runsoftware package will be generated in thebuild_outdirectory.componentrepresents sub-package name, values include ge-compiler, ge-executor and dflow-executor.versionrepresents version number.archrepresents operating system architecture, values include x86_64 and aarch64.4.4 Local Verification (UT/ST)[!NOTE] Note If your compilation environment cannot access the network, please ensure you have completed the Offline Compilation Guide in 4.3 Compilation chapter.After compilation is complete, users can perform developer testing.Compile and executeUTtest cases:# Compile and execute all UT test cases bash tests/run_test.sh --ut # Compile and execute specific UT test cases (recommended) bash tests/run_test.sh --ut${TARGET}--ut (required): You can specify${TARGET}to compile specific objects UT test cases. Available values can be viewed throughbash tests/run_test.sh -h.Compile and executeSTtest cases:# Compile and execute all ST test cases bash tests/run_test.sh --st # Compile and execute specific ST test cases (recommended) bash tests/run_test.sh --st${TARGET}--st (required): You can specify${TARGET}to compile specific objects ST test cases. Available values can be viewed throughbash tests/run_test.sh -h.Collect code coverage:Using the-cparameter of thetests/run_test.shscript can generate code coverage statistics files during test case execution.Prerequisites:Ensurelcovtool is correctly installedgccandgcovon the compilation and runtime environment must be matching versionsUsage:bash tests/run_test.sh -c [other parameters]Output Location: Generated coverage files are located in thecov/directory under the code root directory.Execute specified test cases:After UT/ST execution is complete, you can perform individual testing by directly executing test executable files.Prerequisites:Have executed the corresponding UT/ST test command and correctly generated test executable files.Usage:Example: Have executedbash tests/run_test.sh --utge_common, and want to individually execute and verifyut_libge_multiparts_utest:# UT/ST testing will stub some dependent .so files, need to clear LD_LIBRARY_PATH and ASCEND_OPP_PATH environment variables to avoid interference from CANN/Ascend environment already installed on host machine unset LD_LIBRARY_PATH unset ASCEND_OPP_PATH ./tests/ge/ut/ge/ut_libge_multiparts_utest # You can view included individual cases through --gtest_list_tests, and execute individual cases through --gtest_filter parameterClean build artifacts:UT/STtest case compilation output directories arebuild_utandbuild_st. If you want to clear historical compilation records, you can execute the following operations:rm -rf build_ut/ build_st/ output/ build/ build_out/ cov/[!NOTE] Description Detailed command parameters supported bytests/run_test.shscript can be viewed throughbash tests/run_test.sh -h.4.5 Installation and UninstallationInstallationAfter local verification is complete, you can execute the following command to install the compiledGEsoftware package. When executing the installation command, please ensure the installation user has executable permission for the software package../cann-component_version_arch.run --full --install-path${install_path}[!CAUTION] NoteThe installation path here (whether default or specified) needs to be consistent with the path where Toolkit package was installed earlier. After installation is complete, theGEsoftware package compiled by the user will replace theGErelated software in the already installed CANN development suite package.cann-dflow-executor_version_arch.runsoftware package is only needed when using dflow feature. If only using GE graph compilation and execution functions, you can choose not to install. This package containscann-udf-compat.tar.gz(UDF compatibility upgrade package), which will be loaded to Device side during service startup. During loading process, the driver defaults to performing security signature verification to ensure package trustworthiness. Thecann-udf-compat.tar.gzgenerated by compiling from source code in this repository does not contain signature header, so you must disable the drivers security signature verification mechanism to use it. How to disable signature verification: Disabling signature verification functionality depends on Ascend NPU driver software package (Ascend HDK 25.5.T2.B001 and above versions). You can query version and disable signature verification through the npu-smi tool bundled with this Ascend HDK. For details, see Query Basic Information, Set Custom Signature Verification Capability Enable Status, Set Signature Verification Mode command documentation, need to execute as root user on physical machine (due to permission issues, WebIDE does not support this yet). Taking device 0 as example (where the parameter after -i is device id): npu-smi info # Query basic information, including driver version npu-smi set -t custom-op-secverify-enable -i 0 -d 1 # Enable custom signature verification npu-smi set -t custom-op-secverify-mode -i 0 -d 0 # Set to disable signature verification modeUninstallationIf you want to uninstall the installedcann-component_version_arch.runsoftware package, you can execute the following command../cann-component_version_arch.run --uninstall --install-path${install_path}When executing, you need to replace the software package name in the above command with the actual customcann-component_versionsoftware package name.After installation is complete, you can refer to Sample Execution to run samples.【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表