-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from alvindimas05/main
Many Fixes of Error
- Loading branch information
Showing
8 changed files
with
109 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import platform | ||
import subprocess | ||
import GPUtil | ||
|
||
def get_cpu_info(log) -> [str, str]: | ||
try: | ||
if platform.system() == "Windows": | ||
import wmi | ||
w = wmi.WMI() | ||
CPU = w.Win32_Processor()[0].Name | ||
FREQUENCY = w.Win32_PhysicalMemory()[0].ConfiguredClockSpeed | ||
elif platform.system() == "Darwin": | ||
CPU = subprocess.getoutput("sysctl -n machdep.cpu.brand_string") | ||
FREQUENCY = subprocess.getoutput("echo $(system_profiler SPMemoryDataType | grep Speed | awk '{print $2}') | awk '{print $1}'") | ||
elif platform.system() == "Linux": | ||
CPU = subprocess.getoutput("lscpu | grep 'Model name' | cut -f 2 -d \":\" | awk '{$1=$1}1'") | ||
FREQUENCY = "-" | ||
except Exception as e: | ||
CPU = "Undetected" | ||
FREQUENCY = "-" | ||
log.warning(f"The GPU was not detected, nothing to be concerned about. {e}") | ||
return CPU, FREQUENCY | ||
|
||
def get_gpu_name(log) -> str: | ||
# Ignore GPU on MacOS | ||
if platform.system() == "Darwin": return "" | ||
|
||
try: | ||
# For NVIDIA GPU only | ||
gpus = GPUtil.getGPUs() | ||
gpu_name = gpus[0].name | ||
return gpu_name | ||
except Exception as e: | ||
return _get_gpu_name(log) | ||
|
||
def _get_gpu_name(log) -> str: | ||
try: | ||
if platform.system() == "Windows": | ||
return subprocess.run("wmic path win32_VideoController get name").split("\n\n")[-2].lstrip() | ||
elif platform.system() == "Linux": | ||
return subprocess.getoutput("glxinfo | grep \"Device\"").split("(")[0].lstrip().replace("Device: ", "") | ||
except Exception as e: | ||
log.warning(f"The GPU was not detected, nothing to be concerned about. {e}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters