Commit e90b731a authored by gaoqiong's avatar gaoqiong
Browse files

Merge branch 'v0.0.6_develop_sugon' into 'main'

V0.0.6 develop sugon

See merge request OpenDAS/autoawq_kernels!1
parents 9f217825 264970d1
...@@ -9,7 +9,7 @@ AutoAWQ_kernel是一个从AutoAWQ分离出来的一个组件,以减少编译 ...@@ -9,7 +9,7 @@ AutoAWQ_kernel是一个从AutoAWQ分离出来的一个组件,以减少编译
下载光源的镜像,起dcoker 下载光源的镜像,起dcoker
``` ```
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-centos7.6-dtk24.04-py310 docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-ubuntu20.04-dtk24.04.1-py3.10
# <Image ID>用上面拉取docker镜像的ID替换 # <Image ID>用上面拉取docker镜像的ID替换
# <Host Path>主机端路径 # <Host Path>主机端路径
...@@ -24,42 +24,21 @@ docker run -it --name baichuan --shm-size=1024G -v /opt/hyhal:/opt/hyhal:ro --de ...@@ -24,42 +24,21 @@ docker run -it --name baichuan --shm-size=1024G -v /opt/hyhal:/opt/hyhal:ro --de
根据不同的需求下载不同的分支 根据不同的需求下载不同的分支
- 提供2种源码编译方式(进入AutoAWQ目录): - 提供2种源码编译方式(进入AutoAWQ目录):
``` ```
1. 源码编译安装 export LD_LIBRARY_PATH=/usr/local/lib/python3.10/site-packages/torch/lib:$LD_LIBRARY_PATH
pip3 install e. pip install -r requirements.txt
#源码编译安装
pip3 install e .
2. 编译成whl包安装 #编译成whl包安装
# 安装wheel # 安装wheel
python3 setup.py bdist_wheel python3 setup.py bdist_wheel
cd dist && pip3 install autoawq* cd dist && pip3 install autoawq*
``` ```
## 验证
- python -c "import awq_ext; print(awq_ext.__version__)",版本号与官方版本同步,查询该软件的版本号,例如0.0.6;
## 参考资料
- [README](README.md)
- [https://github.com/casper-hansen/AutoAWQ_kernels](https://github.com/casper-hansen/AutoAWQ_kernels.git)
...@@ -7,6 +7,11 @@ from distutils.sysconfig import get_python_lib ...@@ -7,6 +7,11 @@ from distutils.sysconfig import get_python_lib
from torch.utils.cpp_extension import BuildExtension, CUDAExtension from torch.utils.cpp_extension import BuildExtension, CUDAExtension
from typing import Optional, Union from typing import Optional, Union
pwd = os.path.dirname(__file__)
add_git_version = False
if int(os.environ.get('ADD_GIT_VERSION', '0')) == 1:
add_git_version = True
os.environ["CC"] = "g++" os.environ["CC"] = "g++"
os.environ["CXX"] = "g++" os.environ["CXX"] = "g++"
AUTOAWQ_KERNELS_VERSION = "0.0.6" AUTOAWQ_KERNELS_VERSION = "0.0.6"
...@@ -33,16 +38,21 @@ def get_abi(): ...@@ -33,16 +38,21 @@ def get_abi():
def get_version_add(sha: Optional[str] = None) -> str: def get_version_add(sha: Optional[str] = None) -> str:
command = "git config --global --add safe.directory "+pwd
result = subprocess.run(command, shell=True, capture_output=False, text=True)
version='' version=''
autoawq_root = os.path.dirname(os.path.abspath(__file__)) autoawq_root = os.path.dirname(os.path.abspath(__file__))
add_version_path = os.path.join(os.path.join(autoawq_root, ""), "version.py") add_version_path = os.path.join(os.path.join(autoawq_root, "awq_ext"), "__init__.py")
if sha != 'Unknown': if add_git_version:
if sha is None: if sha != 'Unknown':
sha = get_sha(autoawq_root) if sha is None:
version = 'git' + sha[:7] sha = get_sha(autoawq_root)
version = 'das.opt1.' + sha[:7]
else:
version = 'das.opt1'
# abi # abi
version += "." + get_abi() #version += "." + get_abi()
# dtk version # dtk version
if os.getenv("ROCM_PATH"): if os.getenv("ROCM_PATH"):
...@@ -61,14 +71,19 @@ def get_version_add(sha: Optional[str] = None) -> str: ...@@ -61,14 +71,19 @@ def get_version_add(sha: Optional[str] = None) -> str:
with open(add_version_path, 'r',encoding='utf-8') as file: with open(add_version_path, 'r',encoding='utf-8') as file:
lines = file.readlines() lines = file.readlines()
lines[1] = "__dcu_version__ = '0.0.6+das1.1.{}'\n".format(version) if len(lines) > 1:
lines[1] = "__dcu_version__ = '0.0.6+{}'\n".format(version)
else:
# 如果文件行数不足,可以选择添加空行或者抛出异常
lines.append("__dcu_version__ = '0.0.6+{}'\n".format(version))
print("Added missing line to the file content.")
with open(add_version_path, encoding="utf-8",mode="w") as file: with open(add_version_path, encoding="utf-8",mode="w") as file:
file.writelines(lines) file.writelines(lines)
file.close() file.close()
def get_version(): def get_version():
get_version_add() get_version_add()
version_file = 'version.py' version_file = 'awq_ext/__init__.py'
with open(version_file, encoding='utf-8') as f: with open(version_file, encoding='utf-8') as f:
exec(compile(f.read(), version_file, 'exec')) exec(compile(f.read(), version_file, 'exec'))
return locals()['__dcu_version__'] return locals()['__dcu_version__']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment