已合并
refactor: 消减第三方依赖并补充编译并发选项文档 #656
songkai111创建于 7月20日
refactor: 消减第三方依赖并补充编译并发选项文档 #656
已合并
共 6 个文件变更+9-75
| @@ -27,12 +27,6 @@ | |||
| 27 | bash install_deps.sh | 27 | bash install_deps.sh |
| 28 | ``` | 28 | ``` |
| 29 | 29 | ||
| 30 | -安装完上述依赖后,可通过项目根目录requirements.txt继续安装python三方库依赖,命令如下。 | ||
| 31 | - | ||
| 32 | -```bash | ||
| 33 | -pip3 install -r requirements.txt | ||
| 34 | -``` | ||
| 35 | - | ||
| 36 | ### 安装第三方依赖 | 30 | ### 安装第三方依赖 |
| 37 | 31 | ||
| 38 | > **说明**:对于CANNLab或Docker环境,默认联网,编译过程中会自动下载第三方依赖,无需手动安装,可跳过本章操作。 | 32 | > **说明**:对于CANNLab或Docker环境,默认联网,编译过程中会自动下载第三方依赖,无需手动安装,可跳过本章操作。 |
| @@ -58,9 +52,12 @@ pip3 install -r requirements.txt | |||
| 58 | 进入项目根目录,执行如下编译命令: | 52 | 进入项目根目录,执行如下编译命令: |
| 59 | 53 | ||
| 60 | ```bash | 54 | ```bash |
| 61 | - bash build.sh | 55 | + bash build.sh --pkg [-j${n}] |
| 56 | + # 如:bash build.sh --pkg -j16 | ||
| 62 | ``` | 57 | ``` |
| 63 | 58 | ||
| 59 | + - -j(可选):指定编译线程数,默认值为8,加快编译速度;若超过CPU核心数会自动调整为CPU核心数。 | ||
| 60 | + | ||
| 64 | 若提示如下信息,则说明编译成功。 | 61 | 若提示如下信息,则说明编译成功。 |
| 65 | 62 | ||
| 66 | ```bash | 63 | ```bash |
| @@ -111,7 +108,8 @@ pip3 install -r requirements.txt | |||
| 111 | 请在本项目根目录创建`third_party`目录(若有则无需创建),将第三方软件拷贝到该指定目录。此时编译命令与联网编译命令一致: | 108 | 请在本项目根目录创建`third_party`目录(若有则无需创建),将第三方软件拷贝到该指定目录。此时编译命令与联网编译命令一致: |
| 112 | 109 | ||
| 113 | ```bash | 110 | ```bash |
| 114 | - bash build.sh | 111 | + bash build.sh --pkg [-j${n}] |
| 112 | + # 如:bash build.sh --pkg -j16 | ||
| 115 | ``` | 113 | ``` |
| 116 | 114 | ||
| 117 | - **自定义目录** | 115 | - **自定义目录** |
| @@ -125,8 +123,9 @@ pip3 install -r requirements.txt | |||
| 125 | 此时在联网编译命令基础上额外增加`--cann_3rd_lib_path=${cann_3rd_lib_path}`用于指定第三方软件路径。假设路径为`/path/cann_3rd_lib_path`,编译命令如下: | 123 | 此时在联网编译命令基础上额外增加`--cann_3rd_lib_path=${cann_3rd_lib_path}`用于指定第三方软件路径。假设路径为`/path/cann_3rd_lib_path`,编译命令如下: |
| 126 | 124 | ||
| 127 | ```bash | 125 | ```bash |
| 128 | - bash build.sh --cann_3rd_lib_path=${cann_3rd_lib_path} | 126 | + bash build.sh --pkg --cann_3rd_lib_path=${cann_3rd_lib_path} [-j${n}] |
| 129 | - # bash build.sh --cann_3rd_lib_path=/path/cann_3rd_lib_path | 127 | + # bash build.sh --pkg --cann_3rd_lib_path=/path/cann_3rd_lib_path -j16 |
| 128 | + # bash build.sh --pkg --cann_3rd_lib_path=/path/cann_3rd_lib_path | ||
| 130 | ``` | 129 | ``` |
| 131 | 130 | ||
| 132 | 3. **安装/卸载算子包** | 131 | 3. **安装/卸载算子包** |
| @@ -137,13 +137,6 @@ You can use a project script to automate the installation of these dependencies. | |||
| 137 | ```bash | 137 | ```bash |
| 138 | bash install_deps.sh | 138 | bash install_deps.sh |
| 139 | ``` | 139 | ``` |
| 140 | - | ||
| 141 | - After the installation is complete, install Python third-party dependencies based on `requirements.txt` in the project root directory. | ||
| 142 | - | ||
| 143 | - ```bash | ||
| 144 | - pip3 install -r requirements.txt | ||
| 145 | - ``` | ||
| 146 | - | ||
| 147 | ## Environment Verification | 140 | ## Environment Verification |
| 148 | 141 | ||
| 149 | After installing the CANN package, verify that the environment and driver are normal. | 142 | After installing the CANN package, verify that the environment and driver are normal. |
| @@ -53,7 +53,6 @@ | |||
| 53 | ├── LICENSE # 项目开源许可证信息 | 53 | ├── LICENSE # 项目开源许可证信息 |
| 54 | ├── OAT.xml # 配置脚本,代码仓工具使用,用于检查License是否规范 | 54 | ├── OAT.xml # 配置脚本,代码仓工具使用,用于检查License是否规范 |
| 55 | ├── README.md # 项目工程总介绍文档 | 55 | ├── README.md # 项目工程总介绍文档 |
| 56 | -├── requirements.txt # 项目的第三方依赖包 | ||
| 57 | ├── SECURITY.md # 项目安全声明文件 | 56 | ├── SECURITY.md # 项目安全声明文件 |
| 58 | └── version.info # 项目版本信息 | 57 | └── version.info # 项目版本信息 |
| 59 | ``` | 58 | ``` |
| @@ -139,12 +139,6 @@ | |||
| 139 | bash install_deps.sh | 139 | bash install_deps.sh |
| 140 | ``` | 140 | ``` |
| 141 | 141 | ||
| 142 | - 安装完后,再通过项目根目录requirements.txt继续安装python三方库依赖,命令如下。 | ||
| 143 | - | ||
| 144 | - ```bash | ||
| 145 | - pip3 install -r requirements.txt | ||
| 146 | - ``` | ||
| 147 | - | ||
| 148 | ## 环境验证 | 142 | ## 环境验证 |
| 149 | 143 | ||
| 150 | 安装完CANN包后,需验证环境和驱动是否正常。 | 144 | 安装完CANN包后,需验证环境和驱动是否正常。 |
| @@ -395,55 +395,6 @@ install_git() { | |||
| 395 | fi | 395 | fi |
| 396 | } | 396 | } |
| 397 | 397 | ||
| 398 | -install_googletest() { | ||
| 399 | - local gtest_ver="release-1.11.0" | ||
| 400 | - local gtest_install_prefix="/usr/local" | ||
| 401 | - echo -e "\n==== Checking googletest ====" | ||
| 402 | - | ||
| 403 | - if pkg-config --exists gtest 2>/dev/null; then | ||
| 404 | - echo "googletest has been installed" | ||
| 405 | - return | ||
| 406 | - fi | ||
| 407 | - | ||
| 408 | - if [[ -f "${gtest_install_prefix}/lib/libgtest.a" ]] || [[ -f "${gtest_install_prefix}/lib64/libgtest.a" ]]; then | ||
| 409 | - echo "googletest has been installed" | ||
| 410 | - return | ||
| 411 | - fi | ||
| 412 | - | ||
| 413 | - echo "Installing googletest ${gtest_ver}..." | ||
| 414 | - local tmp_dir=$(mktemp -d) | ||
| 415 | - local orig_dir=$(pwd) | ||
| 416 | - trap "rm -rf ${tmp_dir}" EXIT | ||
| 417 | - | ||
| 418 | - if ! curl -fsSL "https://github.com/google/googletest/archive/refs/tags/${gtest_ver}.tar.gz" -o "${tmp_dir}/googletest.tar.gz"; then | ||
| 419 | - echo "Warning: Failed to download googletest, skipping. You can install it manually later." | ||
| 420 | - rm -rf "${tmp_dir}" | ||
| 421 | - trap - EXIT | ||
| 422 | - cd "${orig_dir}" | ||
| 423 | - return | ||
| 424 | - fi | ||
| 425 | - | ||
| 426 | - tar -xzf "${tmp_dir}/googletest.tar.gz" -C "${tmp_dir}" | ||
| 427 | - local src_dir="${tmp_dir}/googletest-${gtest_ver#release-}" | ||
| 428 | - if [[ ! -d "$src_dir" ]]; then | ||
| 429 | - src_dir=$(find "${tmp_dir}" -maxdepth 1 -type d -name "googletest*" | head -1) | ||
| 430 | - fi | ||
| 431 | - | ||
| 432 | - mkdir -p "${src_dir}/build" && cd "${src_dir}/build" | ||
| 433 | - cmake .. -DCMAKE_INSTALL_PREFIX="${gtest_install_prefix}" -DBUILD_SHARED_LIBS=OFF | ||
| 434 | - make -j$(nproc 2>/dev/null || echo 1) | ||
| 435 | - sudo make install | ||
| 436 | - | ||
| 437 | - cd "${orig_dir}" | ||
| 438 | - rm -rf "${tmp_dir}" | ||
| 439 | - trap - EXIT | ||
| 440 | - | ||
| 441 | - if [[ -f "${gtest_install_prefix}/lib/libgtest.a" ]] || [[ -f "${gtest_install_prefix}/lib64/libgtest.a" ]]; then | ||
| 442 | - echo "googletest installed successfully (${gtest_ver})" | ||
| 443 | - else | ||
| 444 | - echo "Warning: googletest installation may have failed. UT tests require googletest." | ||
| 445 | - fi | ||
| 446 | -} | ||
| 447 | 398 | ||
| 448 | main() { | 399 | main() { |
| 449 | echo "====================================================" | 400 | echo "====================================================" |
| @@ -458,7 +409,6 @@ main() { | |||
| 458 | install_patch | 409 | install_patch |
| 459 | install_dos2unix | 410 | install_dos2unix |
| 460 | install_git | 411 | install_git |
| 461 | - install_googletest | ||
| 462 | 412 | ||
| 463 | echo -e "====================================================" | 413 | echo -e "====================================================" |
| 464 | echo "All dependencies installed successfully!" | 414 | echo "All dependencies installed successfully!" |
Drequirements.txt+0-1
| @@ -1 +0,0 @@ | |||
| 1 | -pyyaml | ||