Optimize a ResNet50* Bfloat16 Inference Container with PyTorch*

ID 732440
Updated 12/9/2020
Version Latest
Public

author-image

By

Pull Command

docker pull intel/image-recognition:pytorch-1.5.0-rc3-resnet50-bfloat16-inference

Description

This document has instructions for running ResNet50* bfloat16 inference using Intel® Extension for PyTorch*.

Datasets

The ImageNet validation dataset is used when testing accuracy. The inference scripts use synthetic data, so no dataset is needed.

Download and extract the ImageNet2012 dataset from http://www.image-net.org/, then move validation images to labeled subfolders, using the valprep.sh shell script

The accuracy script looks for a folder named val, so after running the data prep script, your folder structure should look something like this:

imagenet
└── val
    ├── ILSVRC2012_img_val.tar
    ├── n01440764
    │   ├── ILSVRC2012_val_00000293.JPEG
    │   ├── ILSVRC2012_val_00002138.JPEG
    │   ├── ILSVRC2012_val_00003014.JPEG
    │   ├── ILSVRC2012_val_00006697.JPEG
    │   └── ...
    └── ...

The folder that contains the val directory should be set as the DATASET_DIR when running accuracy (for example: export DATASET_DIR=/home//imagenet).

Quick Start Scripts

Script name Description
bf16_online_inference Runs online inference using synthetic data (batch_size=1).
bf16_batch_inference Runs batch inference using synthetic data (batch_size=128).
bf16_accuracy Measures the model accuracy (batch_size=128).

Docker*

The model container includes the scripts and libraries needed to run ResNet50* bfloat16 inference.

To run the accuracy test, you will need mount a volume and set the DATASET_DIR environment variable to point to the prepped ImageNet validation dataset. The accuracy script also downloads the pretrained model at runtime, so provide proxy environment variables, if necessary.

DATASET_DIR=<path to the dataset folder>

docker run \
  --env DATASET_DIR=${DATASET_DIR} \
  --env http_proxy=${http_proxy} \
  --env https_proxy=${https_proxy} \
  --volume ${DATASET_DIR}:${DATASET_DIR} \
  --privileged --init -t \
  intel/image-recognition:pytorch-1.5.0-rc3-resnet50-bfloat16-inference \
  /bin/bash quickstart/bf16_accuracy.sh

Synthetic data is used when running batch or online inference, so no dataset mount is needed.

docker run \
  --privileged --init -t \
  intel/image-recognition:pytorch-1.5.0-rc3-resnet50-bfloat16-inference \
  /bin/bash quickstart/<script name>.sh

Documentation and Sources

Get Started
Docker*  Repository
Main GitHub*
Readme
Release Notes
Get Started Guide

Code Sources
Dockerfile
Report Issue


License Agreement

LEGAL NOTICE: By accessing, downloading or using this software and any required dependent software (the “Software Package”), you agree to the terms and conditions of the software license agreements for the Software Package, which may also include notices, disclaimers, or license terms for third party software included with the Software Package. Please refer to the license file for additional details.


Related Containers and Solutions

ResNet50* BFloat16 Inference PyTorch* Model Package