Commit add54aa4 authored by xiabo's avatar xiabo
Browse files

适配版本号

parent fafab5d2
......@@ -30,6 +30,6 @@ def parse_version_info(version_str: str, length: int = 4) -> tuple:
return tuple(release)
version_info = tuple(int(x) for x in __version__.split("+")[0].split('.')[:3])
version_info = tuple(int(x) for x in __version__.split('.')[:3])
__all__ = ['__version__', 'version_info', 'parse_version_info']
......@@ -45,6 +45,17 @@ def get_sha(pytorch_root: Union[str, Path]) -> str:
return 'Unknown'
def get_abi():
try:
command = "echo '#include <string>' | gcc -x c++ -E -dM - | fgrep _GLIBCXX_USE_CXX11_ABI"
result = subprocess.run(command, shell=True, capture_output=True, text=True)
output = result.stdout.strip()
abi = "abi" + output.split(" ")[-1]
return abi
except Exception:
return 'abiUnknown'
def get_version_add(sha: Optional[str] = None) -> str:
version=''
mmcv_root = os.path.dirname(os.path.abspath(__file__))
......@@ -54,9 +65,20 @@ def get_version_add(sha: Optional[str] = None) -> str:
sha = get_sha(mmcv_root)
version = 'git' + sha[:7]
if os.getenv('MMCV_BUILD_VERSION'):
version_dtk = os.getenv('MMCV_BUILD_VERSION', "")
version += "." + version_dtk
# abi
version += "." + get_abi()
# dtk version
if os.getenv("ROCM_PATH"):
rocm_path = os.getenv('ROCM_PATH', "")
rocm_version_path = os.path.join(rocm_path, '.info', "rocm_version")
with open(rocm_version_path, 'r',encoding='utf-8') as file:
lines = file.readlines()
rocm_version=lines[0][:-2].replace(".", "")
version += ".dtk" + rocm_version
# torch version
version += ".torch" + torch.__version__[:4]
lines=[]
with open(add_version_path, 'r',encoding='utf-8') as file:
......
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