编译指导
编译说明
本文档介绍如何从源码编译MindIE-Motor,生成 .whl 包,安装与运行。
环境准备
镜像安装方式
MindIE镜像获取请参见镜像安装方式。
容器/物理机安装方式
编译安装
-
安装Python工具.MindIE-Motor 支持 Python == 3.11。
pip install --upgrade pip pip install wheel setuptools -
克隆源码仓库。
git clone https://gitcode.com/Ascend/MindIE-Motor.git cd MindIE-Motor -
根据环境需要,自行设置网络代理。
-
设置以下环境变量禁用证书。
export NO_CHECK_CERTIFICATE=1说明
使用该命令会禁用证书,可能会导致安全风险,需要注意数据保护。您也可以通过手动下载三方zip包进行上传。
-
执行以下命令下载unzip工具。
yum install unzip #openEuler -
编译第三方依赖。
env -u LD_LIBRARY_PATH bash build/build.sh -d 3rd -b 3rdenv -u xxx:表示在启动指定命令时移出环境变量xxx。
-
设置环境变量。 获取 Python site-packages 路径(建议不要强行编码 torch 路径),并配置动态库搜索路径:
TORCH_PATH=$(python3 -c "import torch, os; print(os.path.dirname(torch.__file__))") export LD_LIBRARY_PATH=${TORCH_PATH}/lib:${TORCH_PATH}/../torch.libs:$LD_LIBRARY_PATH可选:指定生成
.whl包的版本号:export MINDIE_MOTOR_VERSION_OVERRIDE=3.0.0 -
编译生成
.whl包。cd mindie_motor/python pip wheel . --no-build-isolation -v- 编译完成后,会在当前目录生成
mindie_motor-<version>-*.whl文件。 - 编译时,
setup.py会自动调用build.sh编译C++代码,并拷贝第三方依赖到包内。 - 编译后,生成临时目录
build、存放二进制的目录output和debug符号表motor_debug_symbols目录。
- 编译完成后,会在当前目录生成
-
安装 MindIE-Motor。
pip install mindie_motor*.whl -
权限配置。 由于whl包安装后是按照系统设定的权限,如下权限可能需要适配(可根据实际权限报错处理),以大EP为例,在boot.sh中添加如下命令:
chmod 500 /usr/local/lib/python3.11/site-packages/mindie_motor/scripts/http_client_ctl/*; chmod 550 /usr/local/lib/python3.11/site-packages/mindie_motor/examples/kubernetes_deploy_scripts/boot_helper/*; chmod 640 /usr/local/lib/python3.11/site-packages/mindie_motor/examples/kubernetes_deploy_scripts/boot_helper/boot.sh; chmod 500 /usr/local/lib/python3.11/site-packages/mindie_motor/scripts/http_client_ctl/*; chmod 700 /root; chmod 640 /usr/local/lib/python3.11/site-packages/mindie_motor/conf/model_config/*.json; chmod 640 /usr/local/lib/python3.11/site-packages/mindie_motor/conf/machine_config/*.json;
升级
详情请参见升级章节。
卸载
详情请参见卸载章节。