Skip to content

Instantly share code, notes, and snippets.

@mkbabb
Last active September 7, 2023 14:29
Show Gist options
  • Save mkbabb/b96870126427813394543020fecd598e to your computer and use it in GitHub Desktop.
Save mkbabb/b96870126427813394543020fecd598e to your computer and use it in GitHub Desktop.
z16 TensorFlow Example.md

1. Install TensorFlow core 2.9

Docker within LinuxONE

List of most recent IBM z containers

Usage Notes

Exposed Ports: 8888

To start container from image & start an application in production mode:

docker run --name tensorflow -it icr.io/ibmz/tensorflow:[version] bash

Prouction mode with exposed ports:

docker run --name tensorflow -it -p 8888:8888 icr.io/ibmz/tensorflow:[version]

Building from Source

Procedure is delineated here

2. Install zDNN >= 0.4.0

Under Linux:

apt-get update && apt-get install -y libzdnn-dev

Or build from source following the official zDNN repo

3. Install IBM-zDNN-Plugin

Using Python 3:

python3 -m pip3 install ibm-zdnn-plugin

Which will install the IBM zDNN plugin into your local Python 3 environment. If you're using a virtual Python env, install it there accordingly.

Example Models

Source document

  • BERT
  • Biomedical Image Segmentation
  • Credit Card Fraud
  • DenseNet121
  • DenseNet169
  • DenseNet201
  • InceptionResNet
  • InceptionV3
  • NASNetLarge
  • NMT
  • ResNet101
  • ResNet152
  • ResNet50
  • VGG16
  • VGG19
  • Xception
  • YOLOV3
  • YOLOv4

4. GitHub Example with Fashion MNIST

IBM-zDNN-Plugin supports inferencing workloads only. Meaning, the accelerator is only active in the latter part of the example.

Preamble

Once both TensorFlow Core, zDNN, and the IBM-zDNN-Plugin are installed, clone the repo here using git under Z:

git clone https://github.com/IBM/ibm-zdnn-plugin.git

Navigate into the samples/fashion-mnist directory

cd ./samples/fashion-mnist

Training and Running

First, train and save the model to disk with the fashion_mnist_training.py script. This will download the fashion MNIST data set and create a model in the current directory.

Training will take some time. The epoch number in the output will indicate progress.

python3 fashion_mnist_training.py

Once the model has been trained, run the fashion_mnist.py script to run inference against the model.

python3 fashion_mnist.py

The script will report a prediction for some sample images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment