File size: 1,468 Bytes
13c6f75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import argparse
from huggingface_hub import HfApi

REPO_ID = "AIEnergyScore/benchmark-hugs-models"
TOKEN = os.environ.get("HF_TOKEN")
API = HfApi(token=TOKEN)

def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--hardware",
        default="a10g-large",
        type=str,
        required=False,
        help="hardware to use for benchmarking.",
    )
    args = parser.parse_args()
    return args
# Based on huggingface_hub _space_api.py
# CPU_BASIC = "cpu-basic"
#     CPU_UPGRADE = "cpu-upgrade"
#     T4_SMALL = "t4-small"
#     T4_MEDIUM = "t4-medium"
#     L4X1 = "l4x1"
#     L4X4 = "l4x4"
#     ZERO_A10G = "zero-a10g"
#     A10G_SMALL = "a10g-small"
#     A10G_LARGE = "a10g-large"
#     A10G_LARGEX2 = "a10g-largex2"
#     A10G_LARGEX4 = "a10g-largex4"
#     A100_LARGE = "a100-large"
#     V5E_1X1 = "v5e-1x1"
#     V5E_2X2 = "v5e-2x2"
#     V5E_2X4 = "v5e-2x4"
#curr_runtime = API.get_space_runtime(repo_id=REPO_ID)
#print(curr_runtime)
#requested_hardware = curr_runtime.requested_hardware
#print(requested_hardware)
#hardware_idx = hardware_options.index(requested_hardware)
#next_hardware = hardware_options[hardware_idx + 1]

if __name__ == '__main__':
    args = parse_args()
    curr_runtime = API.get_space_runtime(repo_id=REPO_ID)
    curr_hardware = curr_runtime.requested_hardware
    if curr_hardware != args.hardware:
        API.request_space_hardware(repo_id=REPO_ID, hardware=args.hardware)