-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
63 lines (54 loc) · 2.01 KB
/
main.py
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import os
import pynvml
import torch
import json
PATH = os.path.dirname(__file__)
PATH_to_Collection = os.path.join(os.path.dirname(__file__),"COllections")
class cmdline:
import argparse
parser = argparse.ArgumentParser(
prog='ColabStation',
description='A platform for collection of Ai tools',
epilog='')
parser.add_argument("-s","--sourceS")
def scan_GPU():
pynvml.nvmlInit()
deviceCount = pynvml.nvmlDeviceGetCount()
for i in range(deviceCount):
handle = pynvml.nvmlDeviceGetHandleByIndex(i)
meminfo = pynvml.nvmlDeviceGetMemoryInfo(handle)
print("GPU", i, ":", pynvml.nvmlDeviceGetName(handle), meminfo.total / (1024 ** 3))
return i
def scan_GPU_total_mem():
pynvml.nvmlInit()
deviceCount = pynvml.nvmlDeviceGetCount()
totalmem = 0
for i in range(deviceCount):
handle = pynvml.nvmlDeviceGetHandleByIndex(i)
meminfo = pynvml.nvmlDeviceGetMemoryInfo(handle)
totalmem = totalmem + meminfo.total
totalmem = totalmem / (1024 ** 3)
return totalmem
def find_env(path): # Search python.exe under certain path
for root, dirs, files in os.walk(path):
for i in dirs:
for r, d, f in os.walk(os.path.join(root,i)):
if 'python.exe' in f:
print(os.path.join(os.path.join(root,i),"python.exe"))
return True
print("Can't find env")
return False
def scan_for_env(): # Search all python.exe location under Collections
for dir in os.listdir(PATH_to_Collection):
if os.path.isdir(os.path.join(PATH_to_Collection, dir)):
print(dir)
find_env(os.path.join(PATH_to_Collection,dir))
print("")
class llm():
def run_model(path_to_config,path_to_model,batch_size,device="GPU0"):
torch.device(device)
torch.compile(json.loads(path_to_config))
## Test area ##
# scan_for_env()
# scan_GPU()
# print(scan_GPU_total_mem())