Spaces:
Configuration error
Configuration error
Download third_party/InternVideo/InternVideo2/multi_modality/tools/utils.py from mazpie/genrl: direct link, hf CLI and curl.
- Browser
- Download file 471 Bytes
-
https://huggingface.co/spaces/mazpie/genrl/resolve/main/third_party/InternVideo/InternVideo2/multi_modality/tools/utils.py
- Command line
-
hf download hf://spaces/mazpie/genrl/third_party/InternVideo/InternVideo2/multi_modality/tools/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/mazpie/genrl/resolve/main/third_party/InternVideo/InternVideo2/multi_modality/tools/utils.py
471 Bytes
| import os | |
| import shutil | |
| import socket | |
| def has_slurm(): | |
| """determine the system has slurm or not | |
| Returns: True if has else False. | |
| """ | |
| return shutil.which("sbatch") is not None | |
| def random_port(): | |
| """random a unused port | |
| Returns: str | |
| """ | |
| with socket.socket() as s: | |
| s.bind(("", 0)) | |
| return s.getsockname()[1] | |
| def runcmd(cmd): | |
| """run command | |
| Args: | |
| cmd (str): The command to run | |
| """ | |
| os.system(cmd) | |