In this tutorial, we will show you how to use Neocortix Cloud Services Scalable Compute to run a distributed batch Python job, in a framework where you can easily substitute your own batch Python code.
First, please follow the steps in the tutorial
Setting Up For Batch Jobs.
After completion of the initial setup, you will have a directory with examples,
~/ncsexamples
.
In the subdirectory
~/ncsexamples/batchMode
you will find the
runBatchPython.py command.
This script creates a set of instances running on mobile devices, one instance for each frame to
be computed (10 in the default example provided).
startFrame = 1,
endFrame = 10,
It will command the instances to install some software, then command each
instance to run the simple example Python code supplied in file
plotFrame.py
, which will generate simple
plots, passing in a frame number to allow each instance to plot a specific frame.
workerScriptPath = 'plotFrame.py'
def frameCmd( self, frameNum ):
pythonFileName = os.path.basename( self.workerScriptPath )
cmd = 'python3 %s %d' % \
(pythonFileName, frameNum)
return cmd
The output of each instance will be a .png file
sine_<n>.png
containing a simple plot. These files will be sent back to the master host, and the master will then terminate the instances.