Running PyTorch
This chapter goes through some example runs with PyTorch. Some output messages have been removed or simplified in the runs for readability.
The sample runs assume that PyTorch and its extra libraries have been installed from the NVIDIA Base Command Manager repository with a package manager. For example with:
yum install cm-pytorch-py37-cuda10.2-gcc8 cm-pytorch-extra-py37-cuda10.2-gcc8
In addition to requiring the extra libraries, PyTorch requires an OpenMPI implementation to work. Chapter 3 of the User Manual describes the different OpenMPI packages that the BCM repositories provide. The different OpenMPI packages allow the user to choose which one to use. For example, depending on which interconnect is being used, or depending on if CUDA support is required.
In this chapter, the cm-openmpi4-cuda10.2-ofed50-gcc8 package is used.
More information on the examples can be found at https://github.com/pytorch/examples.
3.1 Variational Autoencoders
The following example shows how to train Variational Autoencoders (original paper: “Auto-Encoding Variational Bayes” by Diederik P Kingma and Max Welling, https://arxiv.org/abs/1312.6114), powerful generative models that can be used for a wide variety of applications.
The example code is included in the PyTorch extra (cm-pytorch-extra-*) package. Once its module has been loaded, the example directory is defined with the CM_PYTORCH_EXTRA environment variable.
Example
The Variational Autoencoders network is trained by default for 10 epochs. The required dataset can automatically be downloaded and extracted with:
Example
The output sampled digits can be found in the results directory: