|
@ -15,6 +15,69 @@ run_realtime = False |
|
|
data_list_lock = threading.Lock() |
|
|
data_list_lock = threading.Lock() |
|
|
# data_list = [] |
|
|
# data_list = [] |
|
|
|
|
|
|
|
|
|
|
|
table_icon_1 = { |
|
|
|
|
|
'hline': '─', |
|
|
|
|
|
'vline': '│', |
|
|
|
|
|
'hline-d': '╌', |
|
|
|
|
|
'left':{ |
|
|
|
|
|
'up' : '┌', |
|
|
|
|
|
'middle' : '├', |
|
|
|
|
|
'bottom' : '└', |
|
|
|
|
|
}, |
|
|
|
|
|
'mid':{ |
|
|
|
|
|
'up' : '┬', |
|
|
|
|
|
'middle' : '┼', |
|
|
|
|
|
'bottom' : '┴', |
|
|
|
|
|
}, |
|
|
|
|
|
'right':{ |
|
|
|
|
|
'up' : '┐', |
|
|
|
|
|
'middle' : '┤', |
|
|
|
|
|
'bottom' : '┘', |
|
|
|
|
|
}, |
|
|
|
|
|
} |
|
|
|
|
|
table_icon_2 = { |
|
|
|
|
|
'hline': '━', |
|
|
|
|
|
'vline': '┃', |
|
|
|
|
|
'hline-d': '╌', |
|
|
|
|
|
'left':{ |
|
|
|
|
|
'up' : '┏', |
|
|
|
|
|
'middle' : '┣', |
|
|
|
|
|
'bottom' : '┗', |
|
|
|
|
|
}, |
|
|
|
|
|
'mid':{ |
|
|
|
|
|
'up' : '┳', |
|
|
|
|
|
'middle' : '╋', |
|
|
|
|
|
'bottom' : '┻', |
|
|
|
|
|
}, |
|
|
|
|
|
'right':{ |
|
|
|
|
|
'up' : '┓', |
|
|
|
|
|
'middle' : '┫', |
|
|
|
|
|
'bottom' : '┛', |
|
|
|
|
|
}, |
|
|
|
|
|
} |
|
|
|
|
|
table_icon_3 = { |
|
|
|
|
|
'hline': '═', |
|
|
|
|
|
'vline': '║', |
|
|
|
|
|
'hline-d': '╌', |
|
|
|
|
|
'left':{ |
|
|
|
|
|
'up' : '╔', |
|
|
|
|
|
'middle' : '╠', |
|
|
|
|
|
'bottom' : '╚', |
|
|
|
|
|
}, |
|
|
|
|
|
'mid':{ |
|
|
|
|
|
'up' : '╦', |
|
|
|
|
|
'middle' : '╬', |
|
|
|
|
|
'bottom' : '╩', |
|
|
|
|
|
}, |
|
|
|
|
|
'right':{ |
|
|
|
|
|
'up' : '╗', |
|
|
|
|
|
'middle' : '╣', |
|
|
|
|
|
'bottom' : '╝', |
|
|
|
|
|
}, |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
table_icon = table_icon_3 |
|
|
|
|
|
|
|
|
def check_gpu_utilization(server:dict): |
|
|
def check_gpu_utilization(server:dict): |
|
|
# 建立SSH连接 |
|
|
# 建立SSH连接 |
|
|
client = paramiko.SSHClient() |
|
|
client = paramiko.SSHClient() |
|
@ -88,26 +151,6 @@ def print_res(data_list): |
|
|
res = f'{idx}: {status} - {gpu_name} - {diff_len_space}{used_mem} / {total_mem} MiB, GPU Util: {util_gpu} %' |
|
|
res = f'{idx}: {status} - {gpu_name} - {diff_len_space}{used_mem} / {total_mem} MiB, GPU Util: {util_gpu} %' |
|
|
print(res) |
|
|
print(res) |
|
|
|
|
|
|
|
|
table_icon = { |
|
|
|
|
|
'hline': '─', |
|
|
|
|
|
'vline': '│', |
|
|
|
|
|
'left':{ |
|
|
|
|
|
'up' : '┌', |
|
|
|
|
|
'middle' : '├', |
|
|
|
|
|
'bottom' : '└', |
|
|
|
|
|
}, |
|
|
|
|
|
'mid':{ |
|
|
|
|
|
'up' : '┬', |
|
|
|
|
|
'middle' : '┼', |
|
|
|
|
|
'bottom' : '┴', |
|
|
|
|
|
}, |
|
|
|
|
|
'right':{ |
|
|
|
|
|
'up' : '┐', |
|
|
|
|
|
'middle' : '┤', |
|
|
|
|
|
'bottom' : '┘', |
|
|
|
|
|
}, |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def clamp_str(input_str, length, fill=False, fill_type='center', len_is=None): |
|
|
def clamp_str(input_str, length, fill=False, fill_type='center', len_is=None): |
|
|
if len_is: |
|
|
if len_is: |
|
|
ori_len = len_is |
|
|
ori_len = len_is |
|
@ -139,7 +182,7 @@ def get_bar(bar_ratio, max_len, color=False): |
|
|
assert 0 <= bar_ratio <= 1 |
|
|
assert 0 <= bar_ratio <= 1 |
|
|
res = [] |
|
|
res = [] |
|
|
used_len = int(bar_ratio * max_len) |
|
|
used_len = int(bar_ratio * max_len) |
|
|
res.extend(['|'] * used_len) |
|
|
res.extend(['▒'] * used_len) # █ ▒ ▶ ▀ ■ ━ |
|
|
res.extend([' '] * (max_len-used_len)) |
|
|
res.extend([' '] * (max_len-used_len)) |
|
|
|
|
|
|
|
|
if color: |
|
|
if color: |
|
@ -150,7 +193,7 @@ def get_bar(bar_ratio, max_len, color=False): |
|
|
return ''.join(res) |
|
|
return ''.join(res) |
|
|
|
|
|
|
|
|
def get_table_res(data_list): |
|
|
def get_table_res(data_list): |
|
|
def get_line(line_type, width_list, spaces=[]): |
|
|
def get_line(line_type, width_list, spaces=[], dash=False): |
|
|
assert line_type in ['up', 'middle', 'bottom'] |
|
|
assert line_type in ['up', 'middle', 'bottom'] |
|
|
|
|
|
|
|
|
str_list = [] |
|
|
str_list = [] |
|
@ -163,7 +206,10 @@ def get_table_res(data_list): |
|
|
str_list.append(table_icon['left'][line_type]) |
|
|
str_list.append(table_icon['left'][line_type]) |
|
|
|
|
|
|
|
|
# 中间 |
|
|
# 中间 |
|
|
str_list.extend((' ' if i in spaces else table_icon['hline']) * cell) |
|
|
if dash: |
|
|
|
|
|
str_list.extend((' ' if i in spaces else table_icon['hline-d']) * cell) |
|
|
|
|
|
else: |
|
|
|
|
|
str_list.extend((' ' if i in spaces else table_icon['hline']) * cell) |
|
|
|
|
|
|
|
|
# 右边 |
|
|
# 右边 |
|
|
if i == len(width_list) - 1: |
|
|
if i == len(width_list) - 1: |
|
@ -273,7 +319,7 @@ def get_table_res(data_list): |
|
|
|
|
|
|
|
|
# 下一张卡 |
|
|
# 下一张卡 |
|
|
if j != len(info_list)-1: |
|
|
if j != len(info_list)-1: |
|
|
result_str.extend([get_line('middle', cell_width_list, [0]), '\n']) |
|
|
result_str.extend([get_line('middle', cell_width_list, [0], dash=True), '\n']) |
|
|
else: |
|
|
else: |
|
|
str_list = [] |
|
|
str_list = [] |
|
|
str_list.append(table_icon['vline']) |
|
|
str_list.append(table_icon['vline']) |
|
|