#
MNIST on MoAI Platform
The training code provided above is standard PyTorch code used for MNIST classification on MoAI Platform, which is be identical to the code on Nvidia systems. This ensures that users who are already familiar with NVIDIA's ecosystem will find the transition to this code seamless and straightforward.
By running this same code on the MoAI Platform, users can leverage the Moreh AI compiler automatically. The Moreh AI compiler is an advanced tool that optimizes neural network models for performance on a variety of hardware accelerators. This means that, without needing to modify the code, users can benefit from automatic optimizations that enhance both execution speed and efficiency.
Please try running the actual code using the scripts below:
Check Flavor
First, check if you are ready to use the MoAI Platform by verifying the current MoAI Platform version and flavor using moreh-smi
.
$ moreh-smi
+-----------------------------------------------------------------------------------------------------+
| Current Version: 24.11.0 Latest Version: 24.11.0 |
+-----------------------------------------------------------------------------------------------------+
| Device | Name | Model | Memory Usage | Total Memory | Utilization |
+=====================================================================================================+
| 0 | MoAI Accelerator | xLarge.512GB | - | - | - |
+-----------------------------------------------------------------------------------------------------+
Repository Cloning
Clone the repository to bring the example code onto the MoAI Platform.
$ git clone https://github.com/moreh-dev/quickstart.git
$ cd quickstart/moai-example
Run the MNIST Example Code
Run it with the python
command, just like any other Python code.
$ ~/quickstart/moai-example python mnist.py
Monitoring Training Progress
Now, you can observe the MNIST example code training on the MoAI Accelerator.
[info] Requesting resources for MoAI Accelerator from the server...
[info] Initializing the worker daemon for MoAI Accelerator
[info] [1/1] Connecting to resources on the server (192.168.xxx.x:xxxxx)...
[info] Establishing links to the resources...
[info] MoAI Accelerator is ready to use.
[info] Moreh Version: 24.11.0
[info] Moreh Job ID: xxxxxx
Train Epoch: 1 [0/60000 (0%)] Loss: 2.318853
Train Epoch: 1 [640/60000 (0%)] Loss: 1.491962
Train Epoch: 1 [1280/60000 (0%)] Loss: 1.523927
Train Epoch: 1 [1920/60000 (0%)] Loss: 0.891131
Train Epoch: 1 [2560/60000 (0%)] Loss: 0.804795
Train Epoch: 1 [3200/60000 (0%)] Loss: 0.721596
Train Epoch: 1 [3840/60000 (0%)] Loss: 0.560522
Train Epoch: 1 [4480/60000 (0%)] Loss: 0.535770
Train Epoch: 1 [5120/60000 (0%)] Loss: 0.653591
...
🎉 You have successfully trained a simple MNIST classification model on the MoAI Platform. Explore other examples in our Tutorials to deal with more complex and larger models.