Verify the OpenVINO Toolkit and Runtime Installation

About This Task

Once you install the OpenVINO Toolkit from the package repository as described in Set Up the OpenVINO Development Environment, or build and install it as described in Obtain, Build and Install the OpenVINO Toolkit and Runtime, you can use this procedure to source the setup script, install Python3 runtime and development tools, and perform a test to verify it is working properly.

Before You Begin

You must have a successful OpenVINO installation on an eLxr Server development host. This requirement depends on your installation type, for example:

This procedure assumes you are in the $WORKSPACE (/home/workspace) working directory defined earlier in this tutorial.

The terminal prompt should reflect that you are in the environment, for example:

(ov_venv) :~/workspace$

For clarity, the code examples in this procedure do not include this extra detail.

Procedure

For openvino package installations, the first two steps are not required. Go to Step 3, below.

  1. Source the $OPENVINO_REPO/openvino_dist/setupvars.sh script.

    $ source $OPENVINO_REPO/openvino_dist/setupvars.sh
    
  2. Optionally, add the setupvars.sh script to your .bashrc file to automatically configure the environment variables on system startup.

    $ echo "source $OPENVINO_REPO/openvino_dist/setupvars.sh" >> ~/.bashrc
    $ source ~/.bashrc
    
  3. Install the Python dependencies for the OpenVINO runtime and OpenVINO development tools.

    For source installations, run:

    $ python3 -m pip install openvino-dev --find-links $OPENVINO_REPO/openvino_dist/tools
    

    For package installations, run:

    $ python3 -m pip install openvino-dev --find-links /usr/lib/python3/dist-packages/openvino/tools
    
  4. Install and prepare the resnet-50-pytorch model.

    1. Navigate to the $WORKSPACE directory and install the onnx, protobuf, and openvino-dev[pytorch] requirements.

      $ cd $WORKSPACE
      $ mkdir $WORKSPACE/ov_models
      $ pip install onnx protobuf opencv-python-headless openvino-dev[pytorch]
      
    2. Use the omz_downloader to install the resnet-50-pytorch model.

      $ omz_downloader --name resnet-50-pytorch -o $WORKSPACE/ov_models/
      
    3. Update the pytorch_to_onnx.py file to set the weights_only value to False. The existing value defaults to True without any changes to the file, which affects the loading of older PyTorch model weights saved in tar format, and will cause failures with these instructions.

      You must only run the following command once.

      $ sed -i '/torch.load/s/weights,/weights, weights_only=False,/' `find $WORKSPACE -name pytorch_to_onnx.py`
      
    4. Use the omz_converter to convert the resnet-50-pytorch model to OpenVINO FP32 (float point 32-bit) IR (intermediate representation). This will prepare and optimize the model for running the benchmarks.

      $ omz_converter --name resnet-50-pytorch -o $WORKSPACE/ov_models/ -d $WORKSPACE/ov_models/
      
  5. Run the benchmark_app on the resnet-50-pytorch model to verify functionality. You will receive a warning that there is no image; this is expected behavior.

    $ benchmark_app -m $WORKSPACE/ov_models/public/resnet-50-pytorch/FP32/resnet-50-pytorch.xml -d CPU
    
    ../../_images/benchmark_app_cpu-only.png
  6. Run the benchmark_app using an image to test training performance on your system. This requires installing the opencv-python dependency and obtaining the banana.jpg file.

    $ cd $WORKSPACE
    $ wget https://storage.openvinotoolkit.org/data/test_data/images/banana.jpg -O $WORKSPACE/banana.jpg
    $ benchmark_app -m $WORKSPACE/ov_models/public/resnet-50-pytorch/FP32/resnet-50-pytorch.xml -i $WORKSPACE/banana.jpg -d CPU
    
    ../../_images/benchmark_app_cpu-with-image.png
  7. Optionally download and run the benchmark_app with the yolov8n_openvino_model. This also uses the banana.jpg image to verify functionality.

    $ cd $WORKSPACE
    $ pip install opencv-python ultralytics
    $ yolo export model=yolov8n.pt format=openvino
    $ benchmark_app -report_type no_counters -json_stats -m yolov8n_openvino_model/yolov8n.xml -d CPU -hint throughput -inference_only=false -infer_precision f32 -i $WORKSPACE/banana.jpg -t 30 -b 1
    
    ../../_images/benchmark_app_yolov8n-with-report.png

Results

Now that you have verified OpenVINO works on your eLxr 12 system, you can experiment with the sample Pythom programs included with the OpenVINO Toolkit. For details, see Run the OpenVINO Sample Programs.