Running TAO on Google Cloud Platform#

Google Cloud Platform provides the Compute Engine, which is a a computing and hosting service that lets you create and run virtual machines on Google infrastructure. The Compute Engine provides a Linux or a Windows VM. To run TAO, you will need to set up a Linux VM.

Setting up a VM Linux VM Instance#

  1. Instructions to set up a VM are outlined in the official compute engine instructions.

  2. Select a compute engine from the VM Instances option in the console.

  3. Create a new instance using the Create Instance tab

  4. Set the machine family of the instance GPU.

  5. Set boot image to Ubuntu, with the following options:

    Boot disk type: Balanced persistent dist Size (GB) > 200

  6. Select your default network.

  7. Spin up the VM by clicking Create.

Note

NVIDIA recommends using the A2 series of VM instances that are powered by the NVIDIA Tesla A100 GPU’s for best training performance.

Using the VM#

Once you have set up the instance, note the IP address of the VM created from the console.

  1. Set up SSH access

    1. Generate an SSH key from the terminal you intend to use to log in to the created VM. You can do so by running the command below and following the prompts:

      ssh-keygen -t rsa -b 4096
      
    1. Copy the contents of the ~/.ssh/id_rsa.pub file and add it to the instance.

    2. Use the login ID in the public key to log in to the public IP address of the instance.

Setting up the VM and Enabling GPUs#

  1. Prepare the OS dependencies and check the GPUs:

    sudo apt-get update
    sudo apt-get -y upgrade
    sudo apt-get install -y pciutils
    
    lspci | grep -i nvidia
    
  2. Install the NVIDIA GPU driver:

    sudo apt-get -y install nvidia-driver-535
    sudo apt-get -y docker.io
    sudo apt-get install -y python3-pip unzip
    
  3. Install NVIDIA Container Toolkit:

    Follow the instructions given in Installing the NVIDIA Container Toolkit <https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html> to install nvidia-docker.

  4. Log in to the docker registry nvcr.io by running the command below:

    docker login nvcr.io
    

    The username here is $oauthtoken and the password is the NGC API KEY. You may set this API key from the NGC website.

Installing the Pre-requisites for TAO#

  1. Upgrade python-pip to the latest version:

    pip3 install --upgrade pip
    
  2. Install the virtualenv wrapper:

    pip3 install virtualenvwrapper
    
  3. Configure the virtualenv wrapper:

    export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
    export WORKON_HOME=/home/ubuntu/.virtualenvs
    export PATH=/home/ubuntu/.local/bin:$PATH
    source /home/ubuntu/.local/bin/virtualenvwrapper.sh
    

    Note

    You may also add these commands to the ~/.bashrc of the VM to retain them for multiple sessions.

  4. Create a virtualenv for the launcher using the following command:

    mkvirtualenv -p /usr/bin/python3 launcher
    

    Note

    You only need to create a virtualenv once in the instance. When you restart the instance, simply run the commands in step 3 and invoke the same virtual env using the command below:

    workon launcher
    
  5. Install jupyterlab in the virtualenv using the command below

    pip3 install jupyterlab
    

Downloading and Running Test Samples#

Now that you have created a virtualenv and installed all the dependencies, you are now ready to download and run the TAO samples on the notebook. The instructions below assume that you are running the TAO Computer Vision samples.

  1. Download and unzip the notebooks from NGC using the commands below:

    wget --content-disposition https://api.ngc.nvidia.com/v2/resources/nvidia/tao/tao-getting-started/versions/5.0.0/zip -O tao-getting-started_5.0.0.zip
    unzip -u tao-getting-started_5.0.0.zip  -d ./tao-getting-started_5.0.0 && cd ./tao-getting-started_5.0.0
    
  2. Launch the jupyter notebook using the command below:

    jupyter notebook --ip 0.0.0.0 --port 8888 --allow-root --NotebookApp.token=<notebook_token>
    

    This will kick off the jupyter notebook server in the VM. To access this server, navigate to http://<dns_name>:8888/ and enter the <notebook_token> used to start the notebook server, when prompted. The dns_name here is the Public IPv4 DNS of the VM that you noted down earlier.