Upload try_socket.py with huggingface_hub
Browse files- try_socket.py +72 -0
try_socket.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import socket
|
| 2 |
+
|
| 3 |
+
# Get the hostname of the current machine
|
| 4 |
+
hostname = socket.gethostname()
|
| 5 |
+
|
| 6 |
+
print(f"The machine's name is: {hostname}")
|
| 7 |
+
|
| 8 |
+
import socket
|
| 9 |
+
import os
|
| 10 |
+
import psutil
|
| 11 |
+
import GPUtil
|
| 12 |
+
|
| 13 |
+
# Get the hostname of the current machine
|
| 14 |
+
hostname = socket.gethostname()
|
| 15 |
+
|
| 16 |
+
# Get the machine's IP address
|
| 17 |
+
ip_address = socket.gethostbyname(hostname)
|
| 18 |
+
|
| 19 |
+
# Get the machine's node name (equivalent to the hostname)
|
| 20 |
+
node_name = os.uname().nodename
|
| 21 |
+
|
| 22 |
+
# Get the machine's system information
|
| 23 |
+
system_info = os.uname()
|
| 24 |
+
|
| 25 |
+
# Get CPU info
|
| 26 |
+
cpu_info = {
|
| 27 |
+
'physical_cores': psutil.cpu_count(logical=False),
|
| 28 |
+
'total_cores': psutil.cpu_count(logical=True),
|
| 29 |
+
'max_frequency': psutil.cpu_freq().max,
|
| 30 |
+
'current_frequency': psutil.cpu_freq().current,
|
| 31 |
+
'cpu_usage': psutil.cpu_percent(interval=1),
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
# Get memory info
|
| 35 |
+
virtual_memory = psutil.virtual_memory()
|
| 36 |
+
memory_info = {
|
| 37 |
+
'total': virtual_memory.total,
|
| 38 |
+
'available': virtual_memory.available,
|
| 39 |
+
'used': virtual_memory.used,
|
| 40 |
+
'percent': virtual_memory.percent,
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
# Get GPU info
|
| 44 |
+
gpus = GPUtil.getGPUs()
|
| 45 |
+
gpu_info = [{
|
| 46 |
+
'id': gpu.id,
|
| 47 |
+
'name': gpu.name,
|
| 48 |
+
'load': gpu.load,
|
| 49 |
+
'memory_total': gpu.memoryTotal,
|
| 50 |
+
'memory_free': gpu.memoryFree,
|
| 51 |
+
'memory_used': gpu.memoryUsed,
|
| 52 |
+
'temperature': gpu.temperature,
|
| 53 |
+
'uuid': gpu.uuid,
|
| 54 |
+
} for gpu in gpus]
|
| 55 |
+
|
| 56 |
+
machine_info = {
|
| 57 |
+
"hostname": hostname,
|
| 58 |
+
"ip_address": ip_address,
|
| 59 |
+
"node_name": node_name,
|
| 60 |
+
"system_info": {
|
| 61 |
+
"sysname": system_info.sysname,
|
| 62 |
+
"nodename": system_info.nodename,
|
| 63 |
+
"release": system_info.release,
|
| 64 |
+
"version": system_info.version,
|
| 65 |
+
"machine": system_info.machine,
|
| 66 |
+
},
|
| 67 |
+
"cpu_info": cpu_info,
|
| 68 |
+
"memory_info": memory_info,
|
| 69 |
+
"gpu_info": gpu_info,
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
print(machine_info)
|