Download scripts/common/check_environment.py from xiaohaoy/ViewingSoundPAQ: direct link, hf CLI and curl.
- Browser
- Download file 2.2 kB
-
https://huggingface.co/xiaohaoy/ViewingSoundPAQ/resolve/main/scripts/common/check_environment.py
- Command line
-
hf download hf://xiaohaoy/ViewingSoundPAQ/scripts/common/check_environment.py
-
curl -L -o check_environment.py https://huggingface.co/xiaohaoy/ViewingSoundPAQ/resolve/main/scripts/common/check_environment.py
2.2 kB
| #!/usr/bin/env python3 | |
| from __future__ import annotations | |
| import sys as _sys | |
| from pathlib import Path as _Path | |
| _SCRIPTS = next(_p for _p in _Path(__file__).resolve().parents if _p.name == "scripts") | |
| _sys.path[:0] = [str(_SCRIPTS.parent), str(_SCRIPTS.parent / "models")] + [str(_d) for _d in sorted(_SCRIPTS.rglob("*")) if _d.is_dir() and _d.name != "__pycache__"] | |
| import argparse | |
| import platform | |
| def parse_args() -> argparse.Namespace: | |
| parser = argparse.ArgumentParser(description="Check the visual-soundscape environment.") | |
| parser.add_argument( | |
| "--require-cuda", | |
| action="store_true", | |
| help="Exit with an error unless PyTorch can use an NVIDIA CUDA GPU.", | |
| ) | |
| return parser.parse_args() | |
| def main() -> None: | |
| args = parse_args() | |
| import librosa | |
| import numpy | |
| import pandas | |
| import soundfile | |
| import torch | |
| import transformers | |
| if torch.cuda.is_available(): | |
| accelerator = f"CUDA ({torch.cuda.get_device_name(0)})" | |
| elif getattr(torch.backends, "mps", None) and torch.backends.mps.is_available(): | |
| accelerator = "Apple Metal (MPS)" | |
| else: | |
| accelerator = "CPU" | |
| print(f"Python: {platform.python_version()}") | |
| print(f"PyTorch: {torch.__version__}") | |
| print(f"Transformers: {transformers.__version__}") | |
| print(f"NumPy: {numpy.__version__}") | |
| print(f"pandas: {pandas.__version__}") | |
| print(f"librosa: {librosa.__version__}") | |
| print(f"libsndfile: {soundfile.__libsndfile_version__}") | |
| print(f"Accelerator: {accelerator}") | |
| print(f"PyTorch CUDA runtime: {torch.version.cuda or 'none'}") | |
| if torch.cuda.is_available(): | |
| print(f"CUDA devices: {torch.cuda.device_count()}") | |
| print(f"CUDA capability: {torch.cuda.get_device_capability(0)}") | |
| print(f"CUDA bf16 supported: {torch.cuda.is_bf16_supported()}") | |
| if args.require_cuda and not torch.cuda.is_available(): | |
| raise SystemExit( | |
| "ERROR: CUDA is required but unavailable. Check the NVIDIA driver and container " | |
| "GPU passthrough, or intentionally install the CPU backend with " | |
| "'bash setup_env.sh visual-soundscape cpu'." | |
| ) | |
| if __name__ == "__main__": | |
| main() | |