From ca2479be87818ab0b51af529592bfd1244968849 Mon Sep 17 00:00:00 2001 From: Yuxuan Xia <77518229+NovTi@users.noreply.github.com> Date: Thu, 25 Apr 2024 17:24:37 +0800 Subject: [PATCH] Update scripts readme (#10725) * Update scripts readme * Update scripts readme * Update README * Update readme * Update readme * Update windows env check readme * Adjust env check readme * Update windows env check * Update env check readme * Adjust the env-check README * Modify the env-check README --- python/llm/scripts/README.md | 227 +++++++++++++++++++++++++------ python/llm/scripts/check.py | 106 ++++++++++++++- python/llm/scripts/env-check.bat | 8 +- 3 files changed, 289 insertions(+), 52 deletions(-) diff --git a/python/llm/scripts/README.md b/python/llm/scripts/README.md index 70da9858..8623c292 100644 --- a/python/llm/scripts/README.md +++ b/python/llm/scripts/README.md @@ -24,80 +24,100 @@ sudo apt install xpu-smi > If you do not know how to install `ipex-llm`, refer to [IPEX-LLM installation](https://ipex-llm.readthedocs.io/en/latest/doc/LLM/Overview/install.html) for more details. * Within the activated python environment, run below command: * On Linux - ```bash - bash env-check.sh - ``` - * On Windows, - ```bash - env-check.bat - ``` + 1. Install clinfo + ```sudo apt install clinfo``` + + 2. Activate oneapi + Activate the `setvars.sh` file in the folder where you installed the oneapi + + ``` + source /opt/intel/oneapi/setvars.sh + ``` + + 3. Run the env check + ```bash + bash env-check.sh + ``` + + * On Windows + 1. Activate oneapi + Activate the `setvars.bat` file in the folder where you installed the oneapi + + ```bash + call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" + ``` + + 2. Download the XPU manager + Go to the [xpu manager download webpage](https://github.com/intel/xpumanager/releases) to download the latest `xpu-smi` zip file (e.g. xpu-smi-1.2.34-20240417.060819.a50c0371_win.zip). Unzip it and copy the `env-check.bat` and `check.py` files into the unzipped folder. + + 3. Run the env check + In your terminal, enter the unzipped folder and run: + ```bash + env-check.bat + ``` + + 4. Additional Information + If you want to know the GPU memory information, you can use `ctrl+shift+esc` to open the task manager. + Then enter the performance section on the left navigation bar and go to the GPU section, + you can check GPU memory under the `GPU Memory`. ### Sample outputs -* An example output on a Linux Desktop equipped with i9 13900K Intel Core CPU and Intel(R) Arc(TM) A770 GPU looks like below. +* Linux Desktop equipped with i9 12900K Intel Core CPU and Intel(R) Arc(TM) A770 GPU example output: ``` ----------------------------------------------------------------- -PYTHON_VERSION=3.9.19 +PYTHON_VERSION=3.9.18 ----------------------------------------------------------------- transformers=4.31.0 ----------------------------------------------------------------- torch=2.1.0a0+cxx11.abi ----------------------------------------------------------------- -ipex-llm Version: 2.1.0b20240327 +ipex-llm Version: 2.1.0b20240325 ----------------------------------------------------------------- ipex=2.1.10+xpu ----------------------------------------------------------------- CPU Information: -Architecture: x86_64 -CPU op-mode(s): 32-bit, 64-bit -Address sizes: 46 bits physical, 48 bits virtual -Byte Order: Little Endian -CPU(s): 32 -On-line CPU(s) list: 0-31 -Vendor ID: GenuineIntel -Model name: 13th Gen Intel(R) Core(TM) i9-13900K -CPU family: 6 -Model: 183 -Thread(s) per core: 2 -Core(s) per socket: 24 -Socket(s): 1 -Stepping: 1 -CPU max MHz: 5800.0000 -CPU min MHz: 800.0000 -BogoMIPS: 5990.40 +Architecture: x86_64 +CPU op-mode(s): 32-bit, 64-bit +Address sizes: 46 bits physical, 48 bits virtual +Byte Order: Little Endian +CPU(s): 24 +On-line CPU(s) list: 0-23 +Vendor ID: GenuineIntel +Model name: 12th Gen Intel(R) Core(TM) i9-12900K +CPU family: 6 +Model: 151 +Thread(s) per core: 2 +Core(s) per socket: 16 +Socket(s): 1 +Stepping: 2 +CPU max MHz: 5200.0000 +CPU min MHz: 800.0000 +BogoMIPS: 6374.40 ----------------------------------------------------------------- -Total Memory: 62.5479 GB +Total CPU Memory: 62.5343 GB +Memory Type: DDR4 ----------------------------------------------------------------- Operating System: Ubuntu 22.04.3 LTS \n \l ----------------------------------------------------------------- -03:00.0 VGA compatible controller: Intel Corporation Device 56a0 (rev 08) (prog-if 00 [VGA controller]) - Subsystem: Device 1ef7:1307 - Flags: bus master, fast devsel, latency 0, IRQ 201 - Memory at 84000000 (64-bit, non-prefetchable) [size=16M] - Memory at 4000000000 (64-bit, prefetchable) [size=16G] - Expansion ROM at 85000000 [disabled] [size=2M] - Capabilities: - Kernel driver in use: i915 - Kernel modules: i915 ------------------------------------------------------------------ -Linux arda-arc11 5.19.0-41-generic #42~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 18 17:40:00 UTC 2 x86_64 x86_64 x86_64 GNU/Linux +Linux arda-arc05 6.2.0-39-generic #40~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 16 10:53:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux ----------------------------------------------------------------- CLI: - Version: 1.2.13.20230704 + Version: 1.2.22.20231025 Build ID: 00000000 Service: - Version: 1.2.13.20230704 + Version: 1.2.22.20231025 Build ID: 00000000 Level Zero Version: 1.14.0 ----------------------------------------------------------------- - Driver Version 2023.16.11.0.22_160000 - Driver Version 2023.16.11.0.22_160000 - Driver UUID 32332e31-372e-3236-3234-312e33330000 - Driver Version 23.17.26241.33 + Driver Version 2023.16.10.0.17_160000 + Driver Version 2023.16.10.0.17_160000 + Driver UUID 32332e33-352e-3237-3139-312e34320000 + Driver Version 23.35.27191.42 ----------------------------------------------------------------- igpu not detected ----------------------------------------------------------------- @@ -113,5 +133,122 @@ xpu-smi is properly installed. | | DRM Device: /dev/dri/card0 | | | Function Type: physical | +-----------+--------------------------------------------------------------------------------------+ +GPU0 Memory size=16G +----------------------------------------------------------------- +03:00.0 VGA compatible controller: Intel Corporation Device 56a0 (rev 08) (prog-if 00 [VGA controller]) + Subsystem: Device 1ef7:1307 + Flags: bus master, fast devsel, latency 0, IRQ 175 + Memory at 84000000 (64-bit, non-prefetchable) [size=16M] + Memory at 4000000000 (64-bit, prefetchable) [size=16G] + Expansion ROM at 85000000 [disabled] [size=2M] + Capabilities: + Kernel driver in use: i915 + Kernel modules: i915 ----------------------------------------------------------------- ``` + + +* Windows Desktop equipped with i9 13900K Intel Core CPU and Intel(R) Arc(TM) A770 GPU example output: + +``` +Python 3.11.8 +----------------------------------------------------------------- +transformers=4.37.2 +----------------------------------------------------------------- +torch=2.1.0a0+cxx11.abi +----------------------------------------------------------------- +Name: ipex-llm +Version: 2.1.0b20240410 +Summary: Large Language Model Develop Toolkit +Home-page: https://github.com/intel-analytics/BigDLy +Author: BigDL Authors +Author-email: bigdl-user-group@googlegroups.com +License: Apache License, Version 2.0 +Location: C:\Users\arda\miniconda3\envs\ipex-llm-langchain-chatchat\Lib\site-packages +Requires: +Required-by: +----------------------------------------------------------------- +ipex=2.1.10+xpu +----------------------------------------------------------------- +Total Memory: 63.747 GB + +Chip 0 Memory: 32 GB | Speed: 5600 MHz +Chip 1 Memory: 32 GB | Speed: 5600 MHz +----------------------------------------------------------------- +CPU Manufacturer: GenuineIntel +CPU MaxClockSpeed: 3000 +CPU Name: 13th Gen Intel(R) Core(TM) i9-13900K +CPU NumberOfCores: 24 +CPU NumberOfLogicalProcessors: 32 +----------------------------------------------------------------- +GPU 0: Intel(R) Arc(TM) A770 Graphics Driver Version: 31.0.101.5084 +----------------------------------------------------------------- +System Information + +Host Name: DESKTOP-ORSLCSS +OS Name: Microsoft Windows 11 Enterprise +OS Version: 10.0.22631 N/A Build 22631 +OS Manufacturer: Microsoft Corporation +OS Configuration: Member Workstation +OS Build Type: Multiprocessor Free +Registered Owner: Intel User +Registered Organization: Intel Corporation +Product ID: 00330-80000-00000-AA989 +Original Install Date: 4/9/2024, 1:40:07 PM +System Boot Time: 4/12/2024, 12:50:50 PM +System Manufacturer: HP +System Model: HP EliteBook 840 G8 Notebook PC +System Type: x64-based PC +Processor(s): 1 Processor(s) Installed. + [01]: Intel64 Family 6 Model 140 Stepping 1 GenuineIntel ~2995 Mhz +BIOS Version: HP T37 Ver. 01.16.00, 1/18/2024 +Windows Directory: C:\WINDOWS +System Directory: C:\WINDOWS\system32 +Boot Device: \Device\HarddiskVolume1 +System Locale: en-us;English (United States) +Input Locale: en-us;English (United States) +Time Zone: (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi +Total Physical Memory: 16,112 MB +Available Physical Memory: 3,723 MB +Virtual Memory: Max Size: 23,792 MB +Virtual Memory: Available: 9,035 MB +Virtual Memory: In Use: 14,757 MB +Page File Location(s): C:\pagefile.sys +Domain: ccr.corp.intel.com +Logon Server: \\PGSCCR601 +Hotfix(s): 5 Hotfix(s) Installed. + [01]: KB5034467 + [02]: KB5027397 + [03]: KB5036893 + [04]: KB5035967 + [05]: KB5037020 +Network Card(s): 4 NIC(s) Installed. + [01]: Cisco AnyConnect Secure Mobility Client Virtual Miniport Adapter for Windows x64 + Connection Name: Ethernet 3 + Status: Hardware not present + [02]: Intel(R) Wi-Fi 6 AX201 160MHz + Connection Name: Wi-Fi + DHCP Enabled: Yes + DHCP Server: 10.239.27.228 + IP address(es) + [01]: 10.239.44.96 + [02]: fe80::95ba:2f4c:c5bf:74c + [03]: Bluetooth Device (Personal Area Network) + Connection Name: Bluetooth Network Connection + Status: Media disconnected + [04]: PANGP Virtual Ethernet Adapter Secure + Connection Name: Ethernet + DHCP Enabled: No + IP address(es) + [01]: 10.247.2.67 +Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed. +----------------------------------------------------------------- ++-----------+--------------------------------------------------------------------------------------+ +| Device ID | Device Information | ++-----------+--------------------------------------------------------------------------------------+ +| 0 | Device Name: Intel(R) Arc(TM) A770 Graphics | +| | Vendor Name: Intel(R) Corporation | +| | UUID: 00000000-0000-0003-0000-000856a08086 | +| | PCI BDF Address: 0000:03:00.0 | ++-----------+--------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/python/llm/scripts/check.py b/python/llm/scripts/check.py index 71a885f3..5c2f9b3d 100644 --- a/python/llm/scripts/check.py +++ b/python/llm/scripts/check.py @@ -16,6 +16,7 @@ import sys +import subprocess def check_python_version(): @@ -42,7 +43,6 @@ def check_torch_version(): except: print("PyTorch is not installed.") - def check_torch_version(): try: import torch @@ -55,7 +55,6 @@ def check_ipex_llm_version(): if os.system("pip show ipex-llm")!=0: print("ipex-llm is not installed") - def check_ipex_version(): try: import intel_extension_for_pytorch as ipex @@ -63,6 +62,100 @@ def check_ipex_version(): except: print("IPEX is not installed properly. ") + +def check_memory(): + physical_mem = subprocess.run('wmic computersystem get totalphysicalmemory', capture_output=True, text=True).stdout + """ + Example output: + TotalPhysicalMemory + 68448202752 + """ + physical_mem = physical_mem.split('\n') + for i in range(1, len(physical_mem)+1): + if physical_mem[-i].strip().isdigit(): + print(f'Total Memory: {int(physical_mem[-i].strip()) / 1024**3:.3f} GB') + break + + print() + + memory = subprocess.run('wmic memorychip get Capacity, Speed', capture_output=True, text=True).stdout + """ + Example output: + Capacity Speed + 34359738368 3200 + 34359738368 3200 + """ + memory = memory.split('\n\n') + chip_count = 0 + for i in range(1, len(memory)+1): + if memory[-i] != '' and 'Speed' not in memory[-i]: + capacity, speed = memory[-i].strip().split(' ') + + # convert capacity from byte to GB + capacity = str(int(int(capacity) / 1024**3)) + + if capacity.isdigit() and speed.isdigit(): + print(f'Chip {chip_count} Memory: {capacity} GB | Speed: {speed} MHz') + chip_count += 1 + +def check_cpu(): + cpu_info = subprocess.run('wmic cpu get Name, NumberOfCores, NumberOfLogicalProcessors, MaxClockSpeed, Manufacturer', capture_output=True, text=True).stdout + """ + Example output: + Manufacturer MaxClockSpeed Name NumberOfCores NumberOfLogicalProcessors + GenuineIntel 3200 12th Gen Intel(R) Core(TM) i9-12900K 16 24 + """ + + cpu_info = cpu_info.split('\n\n') + names = cpu_info[0] + values = cpu_info[1] + + idx = 0 + while idx < len(names): + if names[idx] != ' ': + start = idx + name_end = names[start:].find(' ') + start + + # for slicing the value + value_end = name_end + 1 + while value_end < len(names) and names[value_end] == ' ': + value_end += 1 + + # updagte idx + idx = value_end + + # get the slicing for the values + value_end -= 2 + print(f'CPU {names[start:name_end]}: {values[start:value_end]}') + else: + idx += 1 + +def check_gpu_driver(): + gpu_driver_info = subprocess.run("wmic path Win32_PnPSignedDriver where \"Description like '%Intel%' and Description like '%Graphics%'\" get DeviceName, DriverVersion", capture_output=True, text=True).stdout + """ + Example output: + DeviceName DriverVersion + Intel(R) Graphics System Controller Auxiliary Firmware Interface 2322.4.7.0 + Intel(R) Graphics System Controller Firmware Interface 2337.5.3.0 + Intel(R) Graphics Command Center 31.0.101.5084 + Intel(R) Arc(TM) A770 Graphics 31.0.101.5084 + """ + gpu_driver_info = gpu_driver_info.split('\n\n') + driver_info = [] + + # filter the information + for i in gpu_driver_info[1:]: + if i != '': + if 'Controller' not in i and 'Command Center' not in i: + driver_info.append(i.strip()) + + # print the gpu driver info + gpu_num = 0 + for gpu in driver_info: + splitted = gpu.split(' ') + print(f'GPU {gpu_num}: {splitted[0]} \t Driver Version: {splitted[-1]}') + gpu_num += 1 + def main(): if check_python_version()!=0: return -1 @@ -74,8 +167,13 @@ def main(): check_ipex_llm_version() print("-----------------------------------------------------------------") check_ipex_version() - - + print("-----------------------------------------------------------------") + check_memory() + print("-----------------------------------------------------------------") + check_cpu() + print("-----------------------------------------------------------------") + check_gpu_driver() + print("-----------------------------------------------------------------") if __name__ == "__main__": main() \ No newline at end of file diff --git a/python/llm/scripts/env-check.bat b/python/llm/scripts/env-check.bat index 90b21daa..81dcccfd 100644 --- a/python/llm/scripts/env-check.bat +++ b/python/llm/scripts/env-check.bat @@ -1,9 +1,9 @@ @echo off - +REM Check Python version python -V if ERRORLEVEL 1 ( - echo No Python found! How to create environment could be found in the README.md + echo No Python found! Instructions on how to create an environment can be found in the README.md. goto:end ) python check.py @@ -12,8 +12,10 @@ echo ----------------------------------------------------------------- echo System Information systeminfo echo ----------------------------------------------------------------- -xpu-smi.exe +xpu-smi discovery if ERRORLEVEL 1 ( echo xpu-smi is not installed properly. goto:end ) + +:end