Commit afdca1a1 authored by panning's avatar panning
Browse files

add dcu_version

parent 25729a99
...@@ -37,6 +37,18 @@ with open(version_txt, 'r') as f: ...@@ -37,6 +37,18 @@ with open(version_txt, 'r') as f:
sha = 'Unknown' sha = 'Unknown'
package_name = 'torchvision' package_name = 'torchvision'
dcu_version = version
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'
try: try:
sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=cwd).decode('ascii').strip() sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=cwd).decode('ascii').strip()
except Exception: except Exception:
...@@ -44,14 +56,27 @@ except Exception: ...@@ -44,14 +56,27 @@ except Exception:
if os.getenv('BUILD_VERSION'): if os.getenv('BUILD_VERSION'):
version = os.getenv('BUILD_VERSION') version = os.getenv('BUILD_VERSION')
elif sha != 'Unknown': #elif sha != 'Unknown':
version += '+' + sha[:7] # version += '+' + sha[:7]
if sha != 'Unknown':
dcu_version += '+git' + sha[:7]
dcu_version += "." + get_abi()
if os.getenv("ROCM_PATH"):
rocm_path = os.getenv('ROCM_PATH', "")
rocm_version_path = os.path.join(rocm_path, '.info', "version-dev")
with open(rocm_version_path, 'r',encoding='utf-8') as file:
lines = file.readlines()
rocm_version=lines[0][:-2].replace(".", "")
dcu_version += ".dtk" + rocm_version
# torch version
dcu_version += ".torch" + torch.__version__[:-2]
def write_version_file(): def write_version_file():
version_path = os.path.join(cwd, 'torchvision', 'version.py') version_path = os.path.join(cwd, 'torchvision', 'version.py')
with open(version_path, 'w') as f: with open(version_path, 'w') as f:
f.write("__version__ = '{}'\n".format(version)) f.write("__version__ = '{}'\n".format(version))
f.write("__dcu_version__ = '{}'\n".format(dcu_version))
f.write("git_version = {}\n".format(repr(sha))) f.write("git_version = {}\n".format(repr(sha)))
f.write("from torchvision.extension import _check_cuda_version\n") f.write("from torchvision.extension import _check_cuda_version\n")
f.write("if _check_cuda_version() > 0:\n") f.write("if _check_cuda_version() > 0:\n")
...@@ -464,7 +489,7 @@ if __name__ == "__main__": ...@@ -464,7 +489,7 @@ if __name__ == "__main__":
setup( setup(
# Metadata # Metadata
name=package_name, name=package_name,
version=version, version=dcu_version,
author='PyTorch Core Team', author='PyTorch Core Team',
author_email='soumith@pytorch.org', author_email='soumith@pytorch.org',
url='https://github.com/pytorch/vision', url='https://github.com/pytorch/vision',
......
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