Run example applications

In this tutorial you learn how to run a sample application in the SambaFlow™ stack and how to use application parameters.

Prerequisites

This tutorial assumes that:

  • You’ve downloaded the sambaflow package and checked that the SambaNova daemon is running.

  • Created a directory $HOME/sambaflow-apps and copied all the example applications into it. That way you will be able to modify them if necessary.

  • Created a directory $HOME/app-test where you will collect applications output: PEF files and logs.

See the Hello SambaFlow! tutorial.

Power PCA starter application

Starter applications are in the $HOME/sambaflow-apps/starters directory. In Hello SambaFlow! Compile and run a model, you learn about the LogReg example. This page discusses the Power PCA example.

The Power PCA example computes principal components using a Power iteration method: https://en.wikipedia.org/wiki/Power_iteration.

The main script is located at $HOME/sambaflow-apps/starters/pytorch/power_pca.py.

Compile

To compile the application, run the following commands.

$ export OUTDIR=$HOME/app-test
$ source /opt/sambaflow/apps/starters/power_pca/venv/bin/activate
$ python $HOME/sambaflow-apps/starters/power_pca/power_pca.py compile \
  --inference \
  --rows 512 \
  --cols 512 \
  --metapipe-disable \
  --pef-name="power_pca" \
  --output-folder=${OUTDIR}

Run

To run the application, run the following commands.

$ export OUTDIR=$HOME/app-test
$ source /opt/sambaflow/apps/starters/power_pca/venv/bin/activate
$ python $HOME/sambaflow-apps/starters/pytorch/power_pca.py run \
  --rows 512 \
  --cols 512 \
  --pef=${OUTDIR}/power_pca/power_pca.pef