介绍
本文系统为ubuntu18.04,并且已经安装好cuda,版本为对应aimet的1.26.0版本需要的11.1,1.26版本以后的aimet只支持ubuntu20的。可以具体到文件里去看。
第一步:创建虚拟环境
conda create -n py38_1.26.0 python=3.8
第二步:安装AImet
下载对应的安装包。在tag里面寻找1.26.0的文件
aimet安装包位置
tag位置
源码位置
链接: https://github.com/quic/aimet/releases
下载以下三个文件
1:AimetTorch-torch_gpu_1.26.0-cp38-cp38-linux_x86_64.whl
2:AimetCommon-torch_gpu_1.26.0-cp38-cp38-linux_x86_64.whl
3:Aimet-torch_gpu_1.26.0-cp38-cp38-linux_x86_64.whl
pip install AimetCommon-torch_gpu_1.26.0-cp38-cp38-linux_x86_64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install Aimet-torch_gpu_1.26.0-cp38-cp38-linux_x86_64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple/
上面不会报错
这一步可能会报错
pip install :AimetTorch-torch_gpu_1.26.0-cp38-cp38-linux_x86_64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple/
如果报错,进入第三步。不报错进入第四步
第三步:配置aimet_torch以及配套环境
1:将源码位置下TraningExtensions/torch/python里面有个aimet_torch文件夹。把这个文件夹复制到 配置的conda 环境下的site-packages文件夹下。和aimet_common在一块
2:手动配置相关环境。
需要的依赖在源码目录下的packaging/dependencies/torch-gpu下面。
(一):安装pytorch
pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple/
(二):安装其他的配套环境。
reqs_pip_common.txt
reqs_pip_torch_common.txt
cumm-cu1110.2.8
spconv-cu1112.1.20
只需要上面的
第四步:环境设置
source (换成对应的conda环境的目录)/site-packages/aimet_common/bin/envsetup.sh
export LD_LIBRARY_PATH=(换成对应的conda环境的目录)/aimet_common/x86_64-linux-gnu:/usr/local/lib/python3.6/dist-packages/aimet_common:$LD_LIBRARY_PATH
if [[ $PYTHONPATH = "" ]]; then export PYTHONPATH=(换成对应的conda环境的目录)/aimet_common/x86_64-linux-gnu; else export PYTHONPATH=(换成对应的conda环境的目录)/aimet_common/x86_64-linux-gnu:$PYTHONPATH; fi
第五步:测试是否安装成功
进入python环境
from aimet_torch.quantsim import QuantizationSimModel
不报错,基本上就成功了
常见问题:
torch 版本不匹配。cuda版本不匹配。没有root权限等等,这上面的操作可以避免root权限。安装官方给的介绍是需要root权限的、
参考
AIMET工具安装介绍(1)
官网