UiPath Activities Guide

Deploying a Local Machine Learning Model

If you want to deploy your own local Machine Learning server to use with the Computer Vision activities follow the steps described in this page

Prerequisites

Hardware Requirements

You need a machine running Ubuntu v16.04 with the following specifications:

minimum
recommended

GPU: nVidia K80

GPU: nVidia P40

Resolution

Time

Resolution

Time

1280x800

1.349

1280x800

0.437

1440x900

1.674

1440x900

0.541

1680x1050

2.124

1680x1050

0.675

1920x1080

2.336

1920x1080

0.756

1920x1200

2.593

1920x1200

0.825

2560x1600

4.180

2560x1600

1.341

Note:

For the rest of the hardware specifications, see the official Ubuntu 16.04 Desktop Edition system requirements.

Software Requirements

After the machine has been provisioned, you must install the following resources:

  • CUDA v9.0
  • cuDNN v7.0
  • Docker v v17.06.2
  • NVIDIA Docker v1.0.0
  • Ubuntu v16.04

Installing the Prerequisites

#!/bin/bash

# Install CUDA and cudnn
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb && \
dpkg -i ./cuda-repo-ubuntu1604_9.0.176-1_amd64.deb && \
apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub && \
apt-get update && \
apt-get install -y cuda-9-0 && \
bash -c 'echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list' && \
apt-get update && \
apt-get install -y --no-install-recommends libcudnn7=7.0.5.15-1+cuda9.0 && \
echo "************** CUDA and CUDNN install SUCCESS! **************" || echo "-------------- CUDA and CUDNN install FAILED! --------------"

# DOCKER

# Set up the docker repository
apt-get update && \
apt-get install apt-transport-https ca-certificates curl software-properties-common && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \ # Install Docker CE -> you might need EE.
apt-get update && \
apt-get install -y docker-ce && \
echo "************** DOCKER install SUCCESS! **************" || echo "-------------- DOCKER install FAILED! --------------"

# NVIDIA Docker

# Add the necessary repository
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  apt-key add - && \
curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/nvidia-docker.list | \
  tee /etc/apt/sources.list.d/nvidia-docker.list && \
apt-get update && \ # install 
apt-get install -y nvidia-docker2 && \
pkill -SIGHUP dockerd && \
echo "************** NVIDIA Docker install SUCCESS! **************" || echo "-------------- NVIDIA Docker install FAILED! --------------"

# change default container runtime


echo "Docker default runtime change."
tee /etc/docker/daemon.json <<EOF
{
   "runtimes": {
       "nvidia": {
           "path": "/usr/bin/nvidia-container-runtime",
           "runtimeArgs": []
       }
   },
   "default-runtime": "nvidia"
}
EOF

Running the Script to Install Prerequisites

On an Ubuntu Machine

  1. Use the sudo su command to switch to administrator mode. A line prompting you for the password is displayed.
  2. Enter the password for the machine and press Enter. You are now connected to the machine with administrator privileges.
  3. Use the vim setup.sh command to create and edit a new text file named setup.sh. This switches to text editing mode.
  4. Copy the script to the clipboard.
  5. Press i to go to INSERT mode and paste the script.
  6. Press ESC to go to NORMAL mode.
  7. Type :x and press enter to save and exit.
  8. Use the chmod +x setup.sh command to turn the setup.sh file into an executable.
  9. Use the ./setup.sh command to run the script. Installation of the software prerequisites commences.
  10. Once the installation is complete, reboot the Ubuntu machine.

By Connecting Remotely via SSH From a Windows Machine

  1. Open a Windows Powershell terminal.
  2. Use the ssh ServerUser@server-ip command, where ServerUser and Server-ip are the user and the IP of the server machine. A line prompting you for the password is displayed.
  3. Enter the password for the machine and press Enter. You are now connected to the Ubuntu terminal.
  4. Use the sudo su command to switch to administrator mode. A line prompting you for the password is displayed.
  5. Enter the password for the machine and press Enter. You are now connected to the machine with administrator privileges.
  6. Use the vim setup.sh command to create and edit a new text file named setup.sh. This switches to text editing mode.
  7. Copy the script to the clipboard.
  8. Press i to go to INSERT mode and paste the script.
  9. Press ESC to go to NORMAL mode.
  10. Type :x and press enter to save and exit.
  11. Use the chmod +x setup.sh command to turn the setup.sh file into an executable.
  12. Use the bash setup.sh command to run the script. Installation of the software prerequisites commences.
  13. Once the installation is complete, reboot the Ubuntu machine.

Deploying the Machine Learning Model

On an Ubuntu Machine

  1. Download the Controls_detection.zip file to your machine from the link provided to you by your sales rep.
  2. Unzip the file by using the unzip Controls_detection.zip command. If no unzip program is installed, run sudo apt-get install zip and press Y when prompted to do so.
  3. Use the cd Controls_detection command to navigate to the Controls_detection folder.
  4. Use the bash start_server.sh command to begin deploying the server.
  5. Wait until the installation is 100% complete and press Ctrl + C to stop any programs that might be running in the background.
  6. Run bash test.sh to test the speed of the neural network.

By Connecting Remotely via SSH From a Windows Machine

  1. Download the Controls_detection.zip file to your machine from the link provided to you by your sales rep.
  2. Open a new PowerShell terminal on the local machine and use cd FULL_PATH_TO_Controls_detection.zip to navigate to the folder where the Controls_detection.zip file is located. For example, if the path of the file is C:\Users\[WINDOWS-USER]\Downloads\Controls_detection.zip, the command should look like cd C:\Users\[WINDOWS-USER]\Downloads\.
  3. Use the scp .\Controls_detection.zip ServerUser@server-ip:/UbuntuPath command to copy the files over to the Ubuntu machine. To find out what the path on the Ubuntu machine is, use the pwd command in the terminal connected via ssh to the Ubuntu machine. For example, if the path is /home/ML-Test, the command should look like scp .\Controls_detection.zip ServerUser@server-ip://home/ML-Test.

Note:

Alternatively, you can use either Putty or WinSCP to connect to the Ubuntu machine and transfer the files without using the scp command.

  1. In the terminal connected to the Ubuntu machine via ssh, unzip the file by using the unzip Controls_detection.zip command. If no unzip program is installed, run sudo apt-get install zip and press Y when prompted to do so.
  2. Use the cd Controls_detection command to navigate to the Controls_detection folder.
  3. Use the .bash start_server.sh command to begin deploying the server.
  4. Wait until the installation is 100% complete and press Ctrl + C to stop any programs that might be running in the background.
  5. Run bash test.sh to test the speed of the neural network.

Connecting to the Computer Vision Server

Important!

Once the server is deployed, to connect to it when using the Computer Vision activities, you must change the value of the URL property of the CV Screen Scope activity to http://[MACHINE_URL]:[PORT]/v1/models/controls_detection:predict where [MACHINE_URL] is the address of the machine where the server is deployed, and [PORT] is the unique port which the Docker container requires. For example, if the URL of your machine is k80-ubuntu.azure.com, and the port you have chosen to work with is 8501, then the value of the property should look like http://k80-ubuntu.azure.com:8501/v1/models/controls_detection:predict.

Also, make sure you have the selected port open on the machine the model is deployed on. To do so, you have to run the following console commands, replacing [PORT] with the actual port you want to use:

# sudo su
# apt install firewalld
# firewall-cmd --add-port [PORT]/tcp

For example, for the default port 8501, the command should look like:

# sudo su
# apt install firewalld
# firewall-cmd --add-port 8501/tcp

The default port through which the model is built to connect through is 8501. It is specified in the ./controls_detection/start_server.sh file. The line -p 8501:8501 designates the chosen port.

Changing the Default Port

To change the default port, you must do the following:

  1. Use the sudo su command to switch to administrator mode. A line prompting you for the password is displayed.
  2. Enter the password for the machine and press Enter. You are now connected to the machine with administrator privileges.
  3. Use the vim setup.sh command to enter text editing mode for the setup.sh file.
  4. Press i to go to INSERT mode and edit the -p 8501:8501 line to -p [NEW_PORT]:8501, where [NEW_PORT] is the port you want to use.
  5. Press ESC to go back to NORMAL mode, type :X and press Enter to save and exit. The default port has been changed.

Deploying a Local Machine Learning Model


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.