def get_directory_size_bytes(dir_path, timeout=10): if not dir_path or not osp.isdir(dir_path): return 0 res = sly.catch_silently(parse_du_hs, dir_path, timeout) if res is None: return -1 # ok, to indicate error return res
def get_load_info(): vmem = psutil.virtual_memory() res = { 'nvidia-smi': sly.catch_silently(print_nvsmi), 'cpu_percent': psutil.cpu_percent(interval=0.1, percpu=True), # @TODO: does the blocking call hit performance? 'memory_B': { 'total': vmem[0], 'available': vmem[1], }, } return res
def get_hw_info(): res = { 'psutil': { 'cpu': { 'count': { 'logical_cores': psutil.cpu_count(logical=True), 'physical_cores': psutil.cpu_count(logical=False), }, }, 'memory_B': { 'physical': psutil.virtual_memory()[0], 'swap': psutil.swap_memory()[0], }, }, 'platform': { 'uname': platform.uname(), }, 'cpuinfo': sly.catch_silently(parse_cpuinfo), 'meminfo': sly.catch_silently(parse_meminfo), 'nvidia-smi': sly.catch_silently(print_nvsmi_devlist), } return res
def get_self_docker_image_digest(): return sly.catch_silently(_get_self_docker_image_digest)