-
Notifications
You must be signed in to change notification settings - Fork 728
Intel® TensorFlow* Model Zoo Inference With FP32 Int8 readme update #1469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jimmytwei
merged 15 commits into
oneapi-src:2023.1.1_AIKit
from
jkinsky:AI-and-AnalyticsFeatures-and-FunctionalityIntelTensorFlow_ModelZoo_Inference_with_FP32_Int8
Mar 24, 2023
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b3bbd56
Fixes for 2023.1 AI Kit (#1409)
jimmytwei 43da45b
Intel® TensorFlow* Model Zoo Inference With FP32 Int8 readme update
jkinsky 64b96a5
Update AI-and-Analytics/Features-and-Functionality/IntelTensorFlow_Mo…
jkinsky eaa19da
Update AI-and-Analytics/Features-and-Functionality/IntelTensorFlow_Mo…
jkinsky 6377eed
Update AI-and-Analytics/Features-and-Functionality/IntelTensorFlow_Mo…
jkinsky 0ce46fe
Update AI-and-Analytics/Features-and-Functionality/IntelTensorFlow_Mo…
jkinsky 7785dec
Update AI-and-Analytics/Features-and-Functionality/IntelTensorFlow_Mo…
jkinsky 9a824ce
Update AI-and-Analytics/Features-and-Functionality/IntelTensorFlow_Mo…
jkinsky a651506
Update AI-and-Analytics/Features-and-Functionality/IntelTensorFlow_Mo…
jkinsky 85b9a2d
Update AI-and-Analytics/Features-and-Functionality/IntelTensorFlow_Mo…
jkinsky 461b3dd
Update AI-and-Analytics/Features-and-Functionality/IntelTensorFlow_Mo…
jkinsky 67eab7c
Update AI-and-Analytics/Features-and-Functionality/IntelTensorFlow_Mo…
jkinsky 39b6295
Update AI-and-Analytics/Features-and-Functionality/IntelPyTorch_Train…
jkinsky 825e8aa
Update AI-and-Analytics/Features-and-Functionality/IntelPyTorch_Train…
jkinsky 22c8d5d
Merge branch '2023.1.1_AIKit' into AI-and-AnalyticsFeatures-and-Funct…
jkinsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Binary file removed
BIN
-13.6 KB
...ity/IntelPyTorch_TrainingOptimizations_AMX_BF16/assets/amx_relative_speedup.png
Binary file not shown.
216 changes: 130 additions & 86 deletions
216
...s-and-Functionality/IntelTensorFlow_ModelZoo_Inference_with_FP32_Int8/README.md
This file contains hidden or 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 |
---|---|---|
@@ -1,122 +1,166 @@ | ||
# `Intel® Model Zoo` Sample | ||
This code example provides a sample code to run ResNet50 inference on Intel's pretrained FP32 and Int8 model | ||
# `Intel® TensorFlow* Model Zoo Inference With FP32 Int8` Sample | ||
|
||
The `Intel® TensorFlow* Model Zoo Inference With FP32 Int8` sample demonstrates how to run ResNet50 inference on pretrained FP32 and Int8 models included in the Model Zoo for Intel® Architecture. | ||
|
||
| Area | Description | ||
|:--- |:--- | ||
| What you will learn | How to perform TensorFlow* ResNet50 inference on synthetic data using FP32 and Int8 pre-trained models. | ||
| Time to complete | 30 minutes | ||
| Category | Code Optimization | ||
|
||
## Purpose | ||
- Demonstrate the AI workloads and deep learning models Intel has optimized and validated to run on Intel hardware | ||
- Show how to efficiently execute, train, and deploy Intel-optimized models | ||
- Make it easy to get started running Intel-optimized models on Intel hardware in the cloud or on bare metal | ||
|
||
***DISCLAIMER: These scripts are not intended for benchmarking Intel platforms. | ||
For any performance and/or benchmarking information on specific Intel platforms, visit [https://www.intel.ai/blog](https://www.intel.ai/blog).*** | ||
The sample intends to help you understand some key concepts: | ||
|
||
## Key implementation details | ||
The example uses Intel's pretrained model published as part of [Intel Model Zoo](https://github.com/IntelAI/models). The example also illustrates how to utilize TensorFlow and MKL run time settings to maximize CPU performance on ResNet50 workload. | ||
- What AI workloads and deep learning models Intel has optimized and validated to run on Intel hardware. | ||
- How to train and deploy Intel-optimized models. | ||
- How to start running Intel-optimized models on Intel hardware in the cloud or on bare metal. | ||
|
||
## License | ||
Code samples are licensed under the MIT license. See | ||
[License.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/License.txt) for details. | ||
> **Disclaimer**: The sample and supplied scripts are not intended for benchmarking Intel platforms. For any performance and/or benchmarking information on specific Intel platforms, visit [https://www.intel.ai/blog](https://www.intel.ai/blog). | ||
|
||
Third party program Licenses can be found here: [third-party-programs.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/third-party-programs.txt) | ||
## Prerequisites | ||
|
||
## Running Samples on the Intel® DevCloud | ||
If you are running this sample on the DevCloud, skip the Pre-requirements and go to the [Activate Conda Environment](#activate-conda) section. | ||
| Optimized for | Description | ||
|:--- |:--- | ||
| OS | Ubuntu* 20.04 or higher | ||
| Hardware | Intel® Core™ Gen10 Processor <br> Intel® Xeon® Scalable Performance processors | ||
| Software | Intel® AI Analytics Toolkit (AI Kit) | ||
|
||
## Pre-requirements (Local or Remote Host Installation) | ||
### For Local Development Environments | ||
|
||
TensorFlow* is ready for use once you finish the Intel® AI Analytics Toolkit (AI Kit) installation and have run the post installation script. | ||
You will need to download and install the following toolkits, tools, and components to use the sample. | ||
|
||
You can refer to the oneAPI [main page](https://software.intel.com/en-us/oneapi) for toolkit installation and the Toolkit [Intel® AI Analytics Toolkit Get Started Guide for Linux](https://software.intel.com/en-us/get-started-with-intel-oneapi-linux-get-started-with-the-intel-ai-analytics-toolkit) for post-installation steps and scripts. | ||
- **Intel® AI Analytics Toolkit (AI Kit)** | ||
|
||
## Activate conda environment With Root Access<a name="activate-conda"></a> | ||
You can get the AI Kit from [Intel® oneAPI Toolkits](https://www.intel.com/content/www/us/en/developer/tools/oneapi/toolkits.html#analytics-kit). <br> See [*Get Started with the Intel® AI Analytics Toolkit for Linux**](https://www.intel.com/content/www/us/en/develop/documentation/get-started-with-ai-linux) for AI Kit installation information and post-installation steps and scripts. | ||
|
||
Navigate the Linux shell to your oneapi installation path, typically `/opt/intel/oneapi`. Activate the conda environment with the following command: | ||
TensorFlow* or Pytorch* are ready for use once you finish installing and configuring the Intel® AI Analytics Toolkit (AI Kit). | ||
|
||
#### Linux | ||
``` | ||
conda activate tensorflow | ||
``` | ||
### For Intel® DevCloud | ||
|
||
The necessary tools and components are already installed in the environment. You do not need to install additional components. See [Intel® DevCloud for oneAPI](https://devcloud.intel.com/oneapi/get_started/) for information. | ||
|
||
## Activate conda environment Without Root Access (Optional) | ||
## Key Implementation Details | ||
|
||
By default, the Intel® AI Analytics Toolkit is installed in the `/opt/intel/oneapi` folder, which requires root privileges to manage it. If you would like to bypass using root access to manage your conda environment, then you can clone your desired conda environment using the following command: | ||
The example uses some pretrained models published as part of the [Model Zoo for Intel® Architecture](https://github.com/IntelAI/models). The example also illustrates how to utilize TensorFlow* and Intel® Math Kernel Library (Intel® MKL) runtime settings to maximize CPU performance on ResNet50 workload. | ||
|
||
#### Linux | ||
``` | ||
conda create --name user_tensorflow --clone tensorflow | ||
``` | ||
## Set Environment Variables | ||
|
||
Then activate your conda environment with the following command: | ||
When working with the command-line interface (CLI), you should configure the oneAPI toolkits using environment variables. Set up your CLI environment by sourcing the `setvars` script every time you open a new terminal window. This practice ensures that your compiler, libraries, and tools are ready for development. | ||
|
||
``` | ||
conda activate user_tensorflow | ||
``` | ||
## Run the `Intel® TensorFlow* Model Zoo Inference With FP32 Int8` Sample | ||
|
||
## Navigate to Intel Model Zoo | ||
### On Linux* | ||
|
||
Navigate to the Intel Model Zoo source directory. It's located in your oneapi installation path, typically `/opt/intel/oneapi/modelzoo`. | ||
You can view the available Model Zoo release versions for the Intel® AI Analytics Toolkit: | ||
``` | ||
ls /opt/intel/oneapi/modelzoo | ||
1.8.0 latest | ||
``` | ||
Then browse to the preferred [Intel Model Zoo](https://github.com/IntelAI/models/tree/master/benchmarks) release version location to run inference for ResNet50 or another supported topology. | ||
``` | ||
cd /opt/intel/oneapi/modelzoo/latest | ||
``` | ||
> **Note**: If you have not already done so, set up your CLI | ||
> environment by sourcing the `setvars` script in the root of your oneAPI installation. | ||
> | ||
> Linux*: | ||
> - For system wide installations: `. /opt/intel/oneapi/setvars.sh` | ||
> - For private installations: ` . ~/intel/oneapi/setvars.sh` | ||
> - For non-POSIX shells, like csh, use the following command: `bash -c 'source <install-dir>/setvars.sh ; exec csh'` | ||
> | ||
> For more information on configuring environment variables, see *[Use the setvars Script with Linux* or macOS*](https://www.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/oneapi-development-environment-setup/use-the-setvars-script-with-linux-or-macos.html)*. | ||
|
||
## Install Jupyter Notebook* | ||
#### Activate Conda with Root Access | ||
|
||
By default, the AI Kit is installed in the `/opt/intel/oneapi` folder and requires root privileges to manage it. However, if you activated another environment, you can return with the following command. | ||
``` | ||
conda install jupyter nb_conda_kernels | ||
conda activate tensorflow | ||
``` | ||
|
||
## How to Build and Run | ||
1. Go to the code example location.<br> | ||
2. If you have GUI support, enter the command `jupyter notebook`. <br> | ||
or<br> | ||
a. If you do not have GUI support, open a remote shell and enter command `jupyter notebook --no-browser --port=8888`.<br> | ||
b. Open the command prompt where you have GUI support, and forward the port from host to client.<br> | ||
c. Enter `ssh -N -f -L localhost:8888:localhost:8888 <userid@hostname>`<br> | ||
d. Copy-paste the URL address from the host into your local browser to open the jupyter console.<br> | ||
3. Go to `ResNet50_Inference.ipynb` and run each cell to create synthetic data and run int8 inference. | ||
|
||
--- | ||
**NOTE** | ||
#### Activate Conda without Root Access (Optional) | ||
|
||
In the jupyter page, be sure to select the correct kernel. In this example, select 'Kernel' -> 'Change kernel' -> Python [conda env:tensorflow]. | ||
You can choose to activate Conda environment without root access. To bypass root access to manage your Conda environment, clone and activate your desired Conda environment using the following commands similar to the following. | ||
|
||
--- | ||
``` | ||
conda create --name user_tensorflow --clone tensorflow | ||
conda activate user_tensorflow | ||
``` | ||
|
||
### **Request a Compute Node** | ||
In order to run on the DevCloud, you need to request a compute node using node properties such as: `gpu`, `xeon`, `fpga_compile`, `fpga_runtime` and others. For more information about the node properties, execute the `pbsnodes` command. | ||
This node information must be provided when submitting a job to run your sample in batch mode using the qsub command. When you see the qsub command in the Run section of the [Hello World instructions](https://devcloud.intel.com/oneapi/get_started/aiAnalyticsToolkitSamples/), change the command to fit the node you are using. Nodes which are in bold indicate they are compatible with this sample: | ||
#### Navigate to Model Zoo | ||
|
||
<!---Mark each compatible Node in BOLD--> | ||
| Node | Command | | ||
| ----------------- | ------------------------------------------------------- | | ||
| GPU | qsub -l nodes=1:gpu:ppn=2 -d . hello-world.sh | | ||
| CPU | qsub -l nodes=1:xeon:ppn=2 -d . hello-world.sh | | ||
| FPGA Compile Time | qsub -l nodes=1:fpga\_compile:ppn=2 -d . hello-world.sh | | ||
| FPGA Runtime | qsub -l nodes=1:fpga\_runtime:ppn=2 -d . hello-world.sh | | ||
Navigate to the Model Zoo for Intel® Architecture source directory. By default, it is in your installation path, like `/opt/intel/oneapi/modelzoo`. | ||
|
||
1. View the available Model Zoo release versions for the AI Kit: | ||
``` | ||
ls /opt/intel/oneapi/modelzoo | ||
2.11.0 latest | ||
``` | ||
2. Navigate to the [Model Zoo Scripts](https://github.com/IntelAI/models/tree/v2.11.0/benchmarks) GitHub repo to determine the preferred released version to run inference for ResNet50 or another supported topology. | ||
``` | ||
cd /opt/intel/oneapi/modelzoo/latest | ||
``` | ||
|
||
### Troubleshooting | ||
If an error occurs, troubleshoot the problem using the Diagnostics Utility for Intel® oneAPI Toolkits. | ||
[Learn more](https://software.intel.com/content/www/us/en/develop/documentation/diagnostic-utility-user-guide/top.html) | ||
#### Install Jupyter Notebook | ||
|
||
### Using Visual Studio Code* (Optional) | ||
``` | ||
conda install jupyter nb_conda_kernels | ||
jkinsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
You can use Visual Studio Code (VS Code) extensions to set your environment, create launch configurations, | ||
and browse and download samples. | ||
#### Open Jupyter Notebook | ||
|
||
1. Change to the sample directory. | ||
jkinsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
2. Launch Jupyter Notebook. | ||
``` | ||
jupyter notebook | ||
``` | ||
> **Note**: If you do not have GUI support, you must open a remote shell and launch the Notebook a different way. | ||
> 1. Enter a command similar to the following: | ||
> ``` | ||
> jupyter notebook --no-browser --port=8888` | ||
> ``` | ||
>2. Open the command prompt where you have GUI support, and forward the port from host to client. | ||
>3. Enter a command similar to the following: | ||
> ``` | ||
> ssh -N -f -L localhost:8888:localhost:8888 <userid@hostname> | ||
> ``` | ||
>4. Copy and paste the URL address from the host into your local browser. | ||
|
||
3. Locate and select the Notebook. | ||
``` | ||
ResNet50_Inference.ipynb | ||
``` | ||
4. Change the kernel to **Python [conda env:tensorflow]**. | ||
5. Click the **Run** button to move through the cells in sequence. | ||
|
||
### Run the Sample on Intel® DevCloud (Optional) | ||
|
||
1. If you do not already have an account, request an Intel® DevCloud account at [*Create an Intel® DevCloud Account*](https://intelsoftwaresites.secure.force.com/DevCloud/oneapi). | ||
2. On a Linux* system, open a terminal. | ||
3. SSH into Intel® DevCloud. | ||
``` | ||
ssh DevCloud | ||
``` | ||
> **Note**: You can find information about configuring your Linux system and connecting to Intel DevCloud at Intel® DevCloud for oneAPI [Get Started](https://devcloud.intel.com/oneapi/get_started). | ||
|
||
4. You can specify a CPU node using a single line script. | ||
``` | ||
qsub -I -l nodes=1:xeon:ppn=2 -d . | ||
``` | ||
|
||
- `-I` (upper case I) requests an interactive session. | ||
- `-l nodes=1:xeon:ppn=2` (lower case L) assigns one full GPU node. | ||
- `-d .` makes the current folder as the working directory for the task. | ||
|
||
|Available Nodes |Command Options | ||
|:--- |:--- | ||
|GPU |`qsub -l nodes=1:gpu:ppn=2 -d .` | ||
jkinsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|CPU |`qsub -l nodes=1:xeon:ppn=2 -d .` | ||
|
||
5. Activate conda. | ||
jkinsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
` $ conda activate` | ||
6. Follow the instructions to open the URL with the token in your browser. | ||
jkinsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
7. Locate and select the Notebook. | ||
jkinsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
ResNet50_Inference.ipynb | ||
```` | ||
8. Change the kernel to **Python [conda env:tensorflow]**. | ||
9. Run every cell in the Notebook in sequence. | ||
|
||
The basic steps to build and run a sample using VS Code include: | ||
- Download a sample using the extension **Code Sample Browser for Intel oneAPI Toolkits**. | ||
- Configure the oneAPI environment with the extension **Environment Configurator for Intel oneAPI Toolkits**. | ||
- Open a Terminal in VS Code (**Terminal>New Terminal**). | ||
- Run the sample in the VS Code terminal using the instructions below. | ||
- (Linux only) Debug your GPU application with GDB for Intel® oneAPI toolkits using the Generate Launch Configurations extension. | ||
## License | ||
|
||
To learn more about the extensions, see | ||
[Using Visual Studio Code with Intel® oneAPI Toolkits](https://software.intel.com/content/www/us/en/develop/documentation/using-vs-code-with-intel-oneapi/top.html). | ||
Code samples are licensed under the MIT license. See | ||
[License.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/License.txt) for details. | ||
|
||
After learning how to use the extensions for Intel oneAPI Toolkits, return to this readme for instructions on how to build and run a sample. | ||
Third party program Licenses can be found here: [third-party-programs.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/third-party-programs.txt). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.