Spaces:
Running
on
Zero
Running
on
Zero
| # utils/version_info.py | |
| import subprocess | |
| import os | |
| import spaces | |
| import torch | |
| import sys | |
| import gradio as gr | |
| git = os.environ.get('GIT', "git") | |
| def commit_hash(): | |
| try: | |
| return subprocess.check_output([git, "rev-parse", "HEAD"], shell=False, encoding='utf8').strip() | |
| except Exception: | |
| return "<none>" | |
| def get_xformers_version(): | |
| try: | |
| import xformers | |
| return xformers.__version__ | |
| except Exception: | |
| return "<none>" | |
| def get_transformers_version(): | |
| try: | |
| import transformers | |
| return transformers.__version__ | |
| except Exception: | |
| return "<none>" | |
| def get_accelerate_version(): | |
| try: | |
| import accelerate | |
| return accelerate.__version__ | |
| except Exception: | |
| return "<none>" | |
| def get_safetensors_version(): | |
| try: | |
| import safetensors | |
| return safetensors.__version__ | |
| except Exception: | |
| return "<none>" | |
| def get_diffusers_version(): | |
| try: | |
| import diffusers | |
| return diffusers.__version__ | |
| except Exception: | |
| return "<none>" | |
| #@spaces.GPU() | |
| def get_torch_info(): | |
| try: | |
| return [torch.__version__, f"CUDA Version:{torch.version.cuda}", f"Available:{torch.cuda.is_available()}", f"flash attention enabled: {torch.backends.cuda.flash_sdp_enabled()}", f"Capabilities: {torch.cuda.get_device_capability(0)}", f"Device Name: {torch.cuda.get_device_name(0)}"] | |
| except Exception: | |
| return "<none>" | |
| def versions_html(): | |
| python_version = ".".join([str(x) for x in sys.version_info[0:3]]) | |
| commit = commit_hash() | |
| # Define the Toggle Dark Mode link with JavaScript | |
| toggle_dark_link = ''' | |
| <a href="#" onclick="document.body.classList.toggle('dark'); return false;" style="cursor: pointer; text-decoration: underline; color: #1a0dab;"> | |
| Toggle Dark Mode | |
| </a> | |
| ''' | |
| # version: <a href="https://github.com/Oncorporation/audiocraft/commit/{"" if commit == "<none>" else commit}" target="_blank">{"click" if commit == "<none>" else commit}</a> | |
| return f""" | |
| version: <a href="https://github.com/Oncorporation/audiocraft/commit/{"" if commit == "<none>" else commit}" target="_blank">{"click" if commit == "<none>" else commit}</a> | |
|  •  | |
| python: <span title="{sys.version}">{python_version}</span> | |
|  •  | |
| torch: {getattr(torch, '__long_version__',torch.__version__)} | |
|  •  | |
| diffusers: {get_diffusers_version()} | |
|  •  | |
| transformers: {get_transformers_version()} | |
|  •  | |
| gradio: {gr.__version__} | |
|  •  | |
| {toggle_dark_link} | |
| <br> | |
| Full GPU Info:{get_torch_info()} | |
| """ |