Intel® DevCloud for oneAPI

Overview Get Started Documentation Forum external link

Before you begin, read the Get Started with the Intel® oneAPI Base Toolkit on the Intel® DevCloud document.

This tutorial gets you started with the Intel® oneAPI AI Analytics Toolkit on the Intel® DevCloud through two basic samples: TensorFlow* HelloWorld and PyTorch* HelloWorld.

Download the Intel AI Analytics Toolkit Samples

  1. Connect to the Intel DevCloud:
    ssh devcloud
  2. Download the samples:
    git clone https://github.com/oneapi-src/oneAPI-samples.git

TensorFlow HelloWorld Walkthrough

Intel optimized the TensorFlow framework using Intel® Deep Neural Network Library (Intel® DNNL) primitives. This sample shows how the optimized TensorFlow enables Intel DNNL calls by default. It implements an example neural network with one convolution layer and one ReLU layer.

Run the sample in batch mode

This section describes how to submit build and run jobs to the Portable Batch System (PBS).

A job is a script that is submitted to PBS through the qsub utility. By default, the qsub utility does not inherit the current environment variables or your current working directory. For this reason, you must submit jobs as scripts that handle the setup of the environment variables. To address the working directory issue, use either the absolute paths or pass the -d <dir> option to qsub to set the working directory.

  1. Go to the sample location:
    cd ~/oneAPI-samples/AI-and-Analytics/Getting-Started-Samples/IntelTensorFlow_GettingStarted
  2. Create a hello-world.sh script with the following contents for executing the sample:
    #!/bin/bash
    source /opt/intel/inteloneapi/setvars.sh  > /dev/null 2>&1
    source activate tensorflow
    python TensorFlow_HelloWorld.py
    

Run

Jobs submitted in batch mode are placed in a queue waiting for the necessary resources (compute nodes) to become available. The jobs will be executed on a first-come basis on the first available node(s) that have the requested property or label.

  1. Run the sample on a gpu node:
    qsub -l nodes=1:gpu:ppn=2 -d . hello-world.sh

    In batch mode, the commands return immediately; however, the job itself may take longer to complete. To inspect the job progress, use the qstat utility:

    watch -n 1 qstat -n -1

    Note: The watch -n 1 command is used to run qstat -n -1 and display its results every second.

  2. To determine whether or not a job was completed, use the qstat utility. When a job terminates, a couple of files are written to the disk:
    .sh.eXXXX, which is the job stderr
    .sh.oXXXX, which is the job stdout
    

    Where XXXX is the job ID that gets printed to the screen after each qsub command.

  3. Inspect the output of the sample:
    cat hello-world.sh.oXXXX
  4. Remove the stdout and stderr files:
    rm hello-world.sh.*

PyTorch HelloWorld Walkthrough

The official PyTorch has been optimized using Intel DNNL primitives by default. This sample shows how to train a PyTorch model and run the inference with Intel DNNL enabled.

  1. Go to the sample location:
    cd ~/oneAPI-samples/AI-and-Analytics/Getting-Started-Samples/IntelPyTorch_GettingStarted
  2. Create a hello-world.sh script with the following contents for executing the sample:
    #!/bin/bash
    source /opt/intel/inteloneapi/setvars.sh  > /dev/null 2>&1
    source activate pytorch
    ./PyTorch_Hello_World.py
    
  3. Run the sample on a gpu node:
    qsub -l nodes=1:gpu:ppn=2 -d . hello-world.sh
  4. Inspect the output of the sample:
    cat hello-world.sh.oXXXX
  5. Remove the stdout and stderr files:
    rm hello-world.sh.*