UX: Script to print env info (#10088)
* env script * update README.md * modify README * modify cpu info output * add env-check.sh * add env-check.bat * add windows * modify bat
This commit is contained in:
parent
b88f447974
commit
03b9c4930a
4 changed files with 435 additions and 0 deletions
187
python/llm/scripts/README.md
Normal file
187
python/llm/scripts/README.md
Normal file
|
|
@ -0,0 +1,187 @@
|
||||||
|
# README
|
||||||
|
Script will first check Python installation, then site-packages (transformers, torch and bigdl-llm), and hardware or operating system and finally check xpu-related issue.
|
||||||
|
## Linux
|
||||||
|
### How to use
|
||||||
|
Run `bash env-check.sh` on linux.
|
||||||
|
### Sample output
|
||||||
|
Here is the output of the scipt on arc12 with GPU installed properly.
|
||||||
|
Note that when only CPU is aviailable, we can ignore xpu related checks.
|
||||||
|
```
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
PYTHON_VERSION=3.9.18
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
transformers=4.37.0
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
torch=2.1.0a0+cxx11.abi
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
BigDL Version: 2.5.0b20240219
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
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
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
MemTotal: 65585208 kB
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
ulimit:
|
||||||
|
real-time non-blocking time (microseconds, -R) unlimited
|
||||||
|
core file size (blocks, -c) 0
|
||||||
|
data seg size (kbytes, -d) unlimited
|
||||||
|
scheduling priority (-e) 0
|
||||||
|
file size (blocks, -f) unlimited
|
||||||
|
pending signals (-i) 255907
|
||||||
|
max locked memory (kbytes, -l) 8198148
|
||||||
|
max memory size (kbytes, -m) unlimited
|
||||||
|
open files (-n) 1048576
|
||||||
|
pipe size (512 bytes, -p) 8
|
||||||
|
POSIX message queues (bytes, -q) 819200
|
||||||
|
real-time priority (-r) 0
|
||||||
|
stack size (kbytes, -s) 8192
|
||||||
|
cpu time (seconds, -t) unlimited
|
||||||
|
max user processes (-u) 255907
|
||||||
|
virtual memory (kbytes, -v) unlimited
|
||||||
|
file locks (-x) unlimited
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
Operating System:
|
||||||
|
Ubuntu 22.04.3 LTS \n \l
|
||||||
|
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
Environment Variable:
|
||||||
|
SHELL=/usr/bin/zsh
|
||||||
|
LSCOLORS=Gxfxcxdxbxegedabagacad
|
||||||
|
TBBROOT=/opt/intel/oneapi/tbb/2021.11/env/..
|
||||||
|
USER_ZDOTDIR=/home/arda
|
||||||
|
COLORTERM=truecolor
|
||||||
|
LESS=-R
|
||||||
|
TERM_PROGRAM_VERSION=1.86.2
|
||||||
|
ONEAPI_ROOT=/opt/intel/oneapi
|
||||||
|
CONDA_EXE=/home/arda/anaconda3/bin/conda
|
||||||
|
_CE_M=
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
xpu-smi is properly installed.
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
+-----------+--------------------------------------------------------------------------------------+
|
||||||
|
| Device ID | Device Information |
|
||||||
|
+-----------+--------------------------------------------------------------------------------------+
|
||||||
|
| 0 | Device Name: Intel(R) Arc(TM) A770 Graphics |
|
||||||
|
| | Vendor Name: Intel(R) Corporation |
|
||||||
|
| | SOC UUID: 00000000-0000-0003-0000-000856a08086 |
|
||||||
|
| | PCI BDF Address: 0000:03:00.0 |
|
||||||
|
| | DRM Device: /dev/dri/card0 |
|
||||||
|
| | Function Type: physical |
|
||||||
|
+-----------+--------------------------------------------------------------------------------------+
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
```
|
||||||
|
|
||||||
|
### FAQs
|
||||||
|
1. How to create environment with proper python version and dependencies?
|
||||||
|
We suggest using conda to manage environment:
|
||||||
|
When CPU-only. Note that after creating environment by commands below, running `bash env-check.sh` will get `ipex not installed` and that is normal.
|
||||||
|
```bash
|
||||||
|
conda create -n llm python=3.9
|
||||||
|
conda activate llm
|
||||||
|
pip install bigdl-llm[all] # install bigdl-llm with 'all' option
|
||||||
|
```
|
||||||
|
When XPU is available. Note that after creating environment by commands below, running `bash env-check.sh` will get ipex version if installed correctly.
|
||||||
|
```bash
|
||||||
|
conda create -n llm python=3.9
|
||||||
|
conda activate llm
|
||||||
|
pip install --pre --upgrade bigdl-llm[xpu] -f https://developer.intel.com/ipex-whl-stable-xpu
|
||||||
|
```
|
||||||
|
If you get messages "Python Version must be higher than 3.9.x" or "No Python found!", we recommend install the virtual environment again with the above commands.
|
||||||
|
|
||||||
|
2. How to install xpu-smi?
|
||||||
|
TODO
|
||||||
|
|
||||||
|
3. Site-package version. Here we list transformers, torch, BigDL and ipex.
|
||||||
|
|
||||||
|
## Windows
|
||||||
|
### How to use
|
||||||
|
Run `env-check.bat` on linux.
|
||||||
|
### Sample output
|
||||||
|
Here is the output of the scipt on the laptop with GPU installed properly.
|
||||||
|
Note that when only CPU is aviailable, we can ignore xpu related checks.
|
||||||
|
```
|
||||||
|
Python 3.9.18
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
transformers=4.37.0
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
torch=2.1.0a0+cxx11.abi
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
Name: bigdl-llm
|
||||||
|
Version: 2.5.0b20240220
|
||||||
|
Summary: Large Language Model Develop Toolkit
|
||||||
|
Home-page: https://github.com/intel-analytics/BigDL
|
||||||
|
Author: BigDL Authors
|
||||||
|
Author-email: bigdl-user-group@googlegroups.com
|
||||||
|
License: Apache License, Version 2.0
|
||||||
|
Location: c:\users\zhicunlv\appdata\local\miniconda3\envs\zhicun\lib\site-packages
|
||||||
|
Requires:
|
||||||
|
Required-by:
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
ipex=2.1.10+xpu
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
System Information
|
||||||
|
|
||||||
|
Host Name: ZHICUNLV-MOBL
|
||||||
|
OS Name: Microsoft Windows 11 Enterprise
|
||||||
|
OS Version: 10.0.22621 N/A Build 22621
|
||||||
|
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-AA731
|
||||||
|
Original Install Date: 1/17/2024, 1:48:03 AM
|
||||||
|
System Boot Time: 2/21/2024, 12:15:27 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 T76 Ver. 01.15.02, 11/15/2023
|
||||||
|
Windows Directory: C:\windows
|
||||||
|
System Directory: C:\windows\system32
|
||||||
|
Boot Device: \Device\HarddiskVolume1
|
||||||
|
System Locale: en-us;English (United States)
|
||||||
|
Input Locale: zh-cn;Chinese (China)
|
||||||
|
Time Zone: (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi
|
||||||
|
Total Physical Memory: 32,496 MB
|
||||||
|
Available Physical Memory: 16,528 MB
|
||||||
|
Virtual Memory: Max Size: 37,360 MB
|
||||||
|
Virtual Memory: Available: 14,926 MB
|
||||||
|
Virtual Memory: In Use: 22,434 MB
|
||||||
|
Page File Location(s): C:\pagefile.sys
|
||||||
|
Domain: ccr.corp.intel.com
|
||||||
|
Logon Server: \\SHSCCR603
|
||||||
|
Hotfix(s): 3 Hotfix(s) Installed.
|
||||||
|
[01]: KB5034467
|
||||||
|
[02]: KB5034765
|
||||||
|
[03]: KB5034225
|
||||||
|
Network Card(s): 3 NIC(s) Installed.
|
||||||
|
[01]: Intel(R) Wi-Fi 6 AX201 160MHz
|
||||||
|
Connection Name: Wi-Fi
|
||||||
|
DHCP Enabled: Yes
|
||||||
|
DHCP Server: 1.1.1.1
|
||||||
|
IP address(es)
|
||||||
|
[01]: 10.238.0.86
|
||||||
|
[02]: fe80::4d61:f10d:d482:8bad
|
||||||
|
[02]: Bluetooth Device (Personal Area Network)
|
||||||
|
Connection Name: Bluetooth Network Connection
|
||||||
|
Status: Media disconnected
|
||||||
|
[03]: Realtek USB GbE Family Controller
|
||||||
|
Connection Name: Ethernet 2
|
||||||
|
Status: Media disconnected
|
||||||
|
Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed.
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
'xpu-smi.exe' is not recognized as an internal or external command,
|
||||||
|
operable program or batch file.
|
||||||
|
xpu-smi is not installed properly.
|
||||||
|
```
|
||||||
64
python/llm/scripts/check.py
Normal file
64
python/llm/scripts/check.py
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def check_python_version():
|
||||||
|
py_version = sys.version.split()[0]
|
||||||
|
lst = py_version.split(".")
|
||||||
|
v1 = eval(lst[0])
|
||||||
|
v2 = eval(lst[1])
|
||||||
|
if v1!=3 or v2<9:
|
||||||
|
print("Python Version must be higher than 3.9.x, please check python version. More details could be found in the README.md")
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def check_transformer_version():
|
||||||
|
try:
|
||||||
|
import transformers
|
||||||
|
print(f"transformers={transformers.__version__}")
|
||||||
|
except:
|
||||||
|
print("Transformers is not installed.")
|
||||||
|
|
||||||
|
def check_torch_version():
|
||||||
|
try:
|
||||||
|
import torch
|
||||||
|
print(f"torch={torch.__version__}")
|
||||||
|
except:
|
||||||
|
print("PyTorch is not installed.")
|
||||||
|
|
||||||
|
|
||||||
|
def check_torch_version():
|
||||||
|
try:
|
||||||
|
import torch
|
||||||
|
print(f"torch={torch.__version__}")
|
||||||
|
except:
|
||||||
|
print("PyTorch is not installed.")
|
||||||
|
|
||||||
|
def check_bigdl_version():
|
||||||
|
import os
|
||||||
|
if os.system("pip show bigdl-llm")!=0:
|
||||||
|
print("BigDL is not installed")
|
||||||
|
|
||||||
|
|
||||||
|
def check_ipex_version():
|
||||||
|
try:
|
||||||
|
import intel_extension_for_pytorch as ipex
|
||||||
|
print(f"ipex={ipex.__version__}")
|
||||||
|
except:
|
||||||
|
print("IPEX is not installed properly. ")
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if check_python_version()!=0:
|
||||||
|
return -1
|
||||||
|
print("-----------------------------------------------------------------")
|
||||||
|
check_transformer_version()
|
||||||
|
print("-----------------------------------------------------------------")
|
||||||
|
check_torch_version()
|
||||||
|
print("-----------------------------------------------------------------")
|
||||||
|
check_bigdl_version()
|
||||||
|
print("-----------------------------------------------------------------")
|
||||||
|
check_ipex_version()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
19
python/llm/scripts/env-check.bat
Normal file
19
python/llm/scripts/env-check.bat
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
|
||||||
|
python -V
|
||||||
|
if ERRORLEVEL 1 (
|
||||||
|
echo No Python found! How to create environment could be found in the README.md
|
||||||
|
goto:end
|
||||||
|
)
|
||||||
|
python check.py
|
||||||
|
|
||||||
|
echo -----------------------------------------------------------------
|
||||||
|
echo System Information
|
||||||
|
systeminfo
|
||||||
|
echo -----------------------------------------------------------------
|
||||||
|
xpu-smi.exe
|
||||||
|
if ERRORLEVEL 1 (
|
||||||
|
echo xpu-smi is not installed properly.
|
||||||
|
goto:end
|
||||||
|
)
|
||||||
165
python/llm/scripts/env-check.sh
Normal file
165
python/llm/scripts/env-check.sh
Normal file
|
|
@ -0,0 +1,165 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
check_python()
|
||||||
|
{
|
||||||
|
# Use this function to check whether Python exists
|
||||||
|
# and guarantee the Python version is higher than 3.9.x
|
||||||
|
# Otherwise, print message for users.
|
||||||
|
echo "-----------------------------------------------------------------"
|
||||||
|
if python -V 2>&1 | awk '{print $2}' >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
PY_VERSION=`python -V 2>&1 | awk '{print $2}'`
|
||||||
|
echo -e "PYTHON_VERSION=$PY_VERSION"
|
||||||
|
v1=`echo $PY_VERSION | awk -F '.' '{print $1}'`
|
||||||
|
v2=`echo $PY_VERSION | awk -F '.' '{print $2}'`
|
||||||
|
if [[ $(expr $v1) -ne 3 ]] || [[ $(expr $v2) -lt 9 ]]
|
||||||
|
then
|
||||||
|
echo "Python Version must be higher than 3.9.x, please check python version. More details could be found in the README.md"
|
||||||
|
retval="1"
|
||||||
|
else
|
||||||
|
retval="0"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No Python found! Please use `conda create -n llm python=3.9` to create environment. More details could be found in the README.md"
|
||||||
|
retval="1"
|
||||||
|
fi
|
||||||
|
return "$retval"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
check_transformers()
|
||||||
|
{
|
||||||
|
echo "-----------------------------------------------------------------"
|
||||||
|
if python -c "import transformers; print(transformers.__version__)" >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
VERSION=`python -c "import transformers; print(transformers.__version__)"`
|
||||||
|
echo "transformers=$VERSION"
|
||||||
|
else
|
||||||
|
echo "Transformers is not installed. "
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_torch()
|
||||||
|
{
|
||||||
|
echo "-----------------------------------------------------------------"
|
||||||
|
if python -c "import torch; print(torch.__version__)" >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
VERSION=`python -c "import torch; print(torch.__version__)"`
|
||||||
|
echo "torch=$VERSION"
|
||||||
|
else
|
||||||
|
echo "PyTorch is not installed. "
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_bigdl()
|
||||||
|
{
|
||||||
|
echo "-----------------------------------------------------------------"
|
||||||
|
echo -n 'BigDL '
|
||||||
|
pip show bigdl-llm | grep Version:
|
||||||
|
}
|
||||||
|
|
||||||
|
check_cpu_info()
|
||||||
|
{
|
||||||
|
echo "-----------------------------------------------------------------"
|
||||||
|
echo "CPU Information: "
|
||||||
|
lscpu | head -n 17
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
check_mem_info()
|
||||||
|
{
|
||||||
|
echo "-----------------------------------------------------------------"
|
||||||
|
cat /proc/meminfo | grep MemTotal
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
check_ulimit()
|
||||||
|
{
|
||||||
|
echo "-----------------------------------------------------------------"
|
||||||
|
echo "ulimit: "
|
||||||
|
ulimit -a
|
||||||
|
}
|
||||||
|
|
||||||
|
check_os()
|
||||||
|
{
|
||||||
|
echo "-----------------------------------------------------------------"
|
||||||
|
echo "Operating System: "
|
||||||
|
cat /etc/issue
|
||||||
|
}
|
||||||
|
|
||||||
|
check_env()
|
||||||
|
{
|
||||||
|
echo "-----------------------------------------------------------------"
|
||||||
|
echo "Environment Variable: "
|
||||||
|
printenv
|
||||||
|
}
|
||||||
|
|
||||||
|
check_xpu_smi_install()
|
||||||
|
{
|
||||||
|
echo "-----------------------------------------------------------------"
|
||||||
|
if xpu-smi -h >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
echo "xpu-smi is properly installed. "
|
||||||
|
return "0"
|
||||||
|
else
|
||||||
|
echo "xpu-smi is not installed. Please install xpu-smi according to README.md"
|
||||||
|
return "1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_xpu_smi()
|
||||||
|
{
|
||||||
|
echo "-----------------------------------------------------------------"
|
||||||
|
xpu-smi discovery
|
||||||
|
}
|
||||||
|
|
||||||
|
check_ipex()
|
||||||
|
{
|
||||||
|
echo "-----------------------------------------------------------------"
|
||||||
|
if python -c "import intel_extension_for_pytorch as ipex; print(ipex.__version__)" >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
VERSION=`python -c "import intel_extension_for_pytorch as ipex; print(ipex.__version__)"`
|
||||||
|
echo "ipex=$VERSION"
|
||||||
|
else
|
||||||
|
echo "IPEX is not installed. "
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
# first guarantee correct python is installed.
|
||||||
|
check_python
|
||||||
|
res=$?
|
||||||
|
if [ $res != 0 ]
|
||||||
|
then
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check site packages version, such as transformers, pytorch, bigdl
|
||||||
|
check_transformers
|
||||||
|
check_torch
|
||||||
|
check_bigdl
|
||||||
|
check_ipex
|
||||||
|
|
||||||
|
# verify hardware (how many gpu availables, gpu status, cpu info, memory info, etc.)
|
||||||
|
check_cpu_info
|
||||||
|
check_mem_info
|
||||||
|
check_ulimit
|
||||||
|
check_os
|
||||||
|
check_env
|
||||||
|
|
||||||
|
# check if xpu-smi and GPU is available.
|
||||||
|
check_xpu_smi_install
|
||||||
|
res=$?
|
||||||
|
if [ $res != 0 ]
|
||||||
|
then
|
||||||
|
exit -1
|
||||||
|
else
|
||||||
|
check_xpu_smi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "-----------------------------------------------------------------"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main
|
||||||
Loading…
Reference in a new issue