Skip to content

Commit 5226448

Browse files
authored
Merge branch 'master' into kaihui/core_dump
2 parents 663921a + 50eb6fb commit 5226448

File tree

25 files changed

+2970
-2
lines changed

25 files changed

+2970
-2
lines changed

.azure-pipelines/scripts/install_nc.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
echo -e "\n Install Neural Compressor ... "
44
cd /neural-compressor
55
if [[ $1 = *"3x_pt"* ]]; then
6+
if [[ $1 != *"3x_pt_fp8"* ]]; then
7+
echo -e "\n Install torch CPU ... "
8+
pip install torch==2.3.0 --index-url https://download.pytorch.org/whl/cpu
9+
fi
610
python -m pip install --no-cache-dir -r requirements_pt.txt
711
python setup.py pt bdist_wheel
812
pip install --no-deps dist/neural_compressor*.whl --force-reinstall

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,29 @@ support AMD CPU, ARM CPU, and NVidia GPU through ONNX Runtime with limited testi
3131
* [2024/07] Performance optimizations and usability improvements on [client-side](https://github.com/intel/neural-compressor/blob/master/docs/source/3x/client_quant.md).
3232

3333
## Installation
34+
### Install Framework
35+
#### Install torch for CPU
36+
```Shell
37+
pip install torch --index-url https://download.pytorch.org/whl/cpu
38+
```
39+
#### Use Docker Image with torch installed for HPU
40+
https://docs.habana.ai/en/latest/Installation_Guide/Bare_Metal_Fresh_OS.html#bare-metal-fresh-os-single-click
41+
42+
#### Install torch/intel_extension_for_pytorch for Intel GPU
43+
https://intel.github.io/intel-extension-for-pytorch/index.html#installation
44+
45+
#### Install torch for other platform
46+
https://pytorch.org/get-started/locally
47+
48+
#### Install tensorflow
49+
```Shell
50+
pip install tensorflow
51+
```
3452

3553
### Install from pypi
3654
```Shell
3755
# Install 2.X API + Framework extension API + PyTorch dependency
38-
pip install neural-compressor[pt]
56+
pip install neural-compressor[pt]
3957
# Install 2.X API + Framework extension API + TensorFlow dependency
4058
pip install neural-compressor[tf]
4159
```

docs/source/installation_guide.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@ The following prerequisites and requirements must be satisfied for a successful
2727
> Notes:
2828
> - If you get some build issues, please check [frequently asked questions](faq.md) at first.
2929
30+
### Install Framework
31+
#### Install torch for CPU
32+
```Shell
33+
pip install torch --index-url https://download.pytorch.org/whl/cpu
34+
```
35+
#### Use Docker Image with torch installed for HPU
36+
https://docs.habana.ai/en/latest/Installation_Guide/Bare_Metal_Fresh_OS.html#bare-metal-fresh-os-single-click
37+
38+
#### Install torch/intel_extension_for_pytorch for Intel GPU
39+
https://intel.github.io/intel-extension-for-pytorch/index.html#installation
40+
41+
#### Install torch for other platform
42+
https://pytorch.org/get-started/locally
43+
44+
#### Install tensorflow
45+
```Shell
46+
pip install tensorflow
47+
```
48+
3049
### Install from Binary
3150
- Install from Pypi
3251
```Shell

examples/.config/model_params_tensorflow_3x.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@
9393
"main_script": "main.py",
9494
"batch_size": 1000
9595
},
96+
"yolo_v5": {
97+
"model_src_dir": "object_detection/yolo_v5/quantization/ptq",
98+
"dataset_location": "/tf_dataset2/datasets/coco_yolov5/coco",
99+
"input_model": "/tf_dataset2/models/tensorflow/yolo_v5/yolov5s.pb",
100+
"main_script": "main.py",
101+
"batch_size": 1
102+
},
96103
"faster_rcnn_resnet50": {
97104
"model_src_dir": "object_detection/faster_rcnn_resnet50/quantization/ptq",
98105
"dataset_location": "/tf_dataset/tensorflow/coco_val.record",
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
Step-by-Step
2+
============
3+
4+
This document describes the step-by-step instructions for reproducing PyTorch tuning results with Intel® Neural Compressor.
5+
6+
# Prerequisite
7+
8+
## 1. Environment
9+
10+
We verified examples with IPEX backend on Python 3.10, recommended.
11+
12+
```shell
13+
pip install -r requirements.txt
14+
```
15+
16+
## 2. Install Intel-Pytorch-Extension
17+
18+
Please refer to [intel/intel-extension-for-pytorch(github.com)](https://github.com/intel/intel-extension-for-pytorch).
19+
20+
### Install IPEX CPU
21+
22+
> Note: GCC9 compiler is recommended
23+
24+
```shell
25+
python -m pip install intel_extension_for_pytorch -f https://software.intel.com/ipex-whl-stable
26+
```
27+
28+
### Install IPEX XPU
29+
Please build an IPEX docker container according to the [official guide](https://intel.github.io/intel-extension-for-pytorch/index.html#installation?platform=gpu&version=v2.1.30%2bxpu&os=linux%2fwsl2&package=docker).
30+
31+
You can run a simple sanity test to double confirm if the correct version is installed, and if the software stack can get correct hardware information onboard your system. The command should return PyTorch and IPEX versions installed, as well as GPU card(s) information detected.
32+
```bash
33+
source {DPCPPROOT}/env/vars.sh
34+
source {MKLROOT}/env/vars.sh
35+
source {CCLROOT}/env/vars.sh
36+
source {MPIROOT}/env/vars.sh
37+
python -c "import torch; import intel_extension_for_pytorch as ipex; print(torch.__version__); print(ipex.__version__); [print(f'[{i}]: {torch.xpu.get_device_properties(i)}') for i in range(torch.xpu.device_count())];"
38+
```
39+
Please also refer to this [tutorial](https://intel.github.io/intel-extension-for-pytorch/index.html#installation?platform=gpu&version=v2.1.30%2bxpu&os=linux%2fwsl2&package=conda) to check system requirements and install dependencies.
40+
41+
## 3. Prepare Dataset
42+
43+
Download [ImageNet](http://www.image-net.org/) Raw image to dir: /path/to/imagenet. The dir include below folder:
44+
45+
```bash
46+
ls /path/to/imagenet
47+
train val
48+
```
49+
50+
# Run with CPU
51+
52+
> Note: All torchvision model names can be passed as long as they are included in `torchvision.models`, below are some examples.
53+
54+
### 1. ResNet18 With Intel PyTorch Extension
55+
56+
```shell
57+
python main.py -t -a resnet18 --ipex --pretrained /path/to/imagenet
58+
```
59+
or
60+
```shell
61+
bash run_quant.sh --input_model=resnet18 --dataset_location=/path/to/imagenet
62+
bash run_benchmark.sh --input_model=resnet18 --dataset_location=/path/to/imagenet --mode=performance/accuracy --int8=true/false
63+
```
64+
65+
### 2. ResNet50 With Intel PyTorch Extension
66+
67+
```shell
68+
python main.py -t -a resnet50 --ipex --pretrained /path/to/imagenet
69+
```
70+
or
71+
```shell
72+
bash run_quant.sh --input_model=resnet50 --dataset_location=/path/to/imagenet
73+
bash run_benchmark.sh --input_model=resnet50 --dataset_location=/path/to/imagenet --mode=performance/accuracy --int8=true/false
74+
```
75+
76+
### 3. ResNext101_32x16d With Intel PyTorch Extension
77+
78+
```shell
79+
python main.py -t -a resnext101_32x16d_wsl --hub --ipex --pretrained /path/to/imagenet
80+
```
81+
or
82+
```shell
83+
bash run_quant.sh --input_model=resnext101_32x16d_wsl --dataset_location=/path/to/imagenet
84+
bash run_benchmark.sh --input_model=resnext101_32x16d_wsl --dataset_location=/path/to/imagenet --mode=performance/accuracy --int8=true/false
85+
```
86+
87+
# Run with XPU
88+
89+
> Note: All torchvision model names can be passed as long as they are included in `torchvision.models`, below are some examples.
90+
91+
### 1. ResNet18 With Intel PyTorch Extension
92+
93+
```shell
94+
python main.py -t -a resnet18 --ipex --pretrained /path/to/imagenet --xpu
95+
```
96+
or
97+
```shell
98+
bash run_quant.sh --input_model=resnet18 --dataset_location=/path/to/imagenet
99+
bash run_benchmark.sh --input_model=resnet18 --dataset_location=/path/to/imagenet --mode=performance/accuracy --int8=true/false --xpu=true/false
100+
```

0 commit comments

Comments
 (0)