Advanced Tutorial PyTorch Python PythonPip AI

Example 1: Installing PyTorch using the PythonPip module

Introduction

The module PythonPip allows you to install additional Python packages to be used in MeVisLab.

The module either allows to install packages into the global MeVisLab installation directory, or into your defined user package. We will use the user package directory, because then the installed packages remain available in your packages even if you uninstall or update MeVisLab. In addition to that, no administrative rights are necessary if you did install MeVisLab for all users.

Steps to do

The PythonPip module

Add a PythonPip module to your workspace.

PythonPip module

PythonPip module

Double-click Left Mouse Button the module and inspect the panel.

PythonPip panel

PythonPip panel

The panel shows all currently installed Python packages including their version and the MeVisLab package they are saved in. You can see a warning that the target package is set to read-only in case you are selecting a MeVisLab package. Changing to one of your user packages (see Example 2.1: Package creation for details) makes the warning disappear.

Select user package

Select user package

Install torch and torchvision

For our tutorials, we need to install torch and torchvision. Enter torch torchvision into the Command textbox and press Install.

Continuing with CUDA support:

Command

torch torchvision --index-url https://download.pytorch.org/whl/cu117

Install torch and torchvision

Install torch and torchvision

After clicking Install, the pip console output opens and you can follow the process of the installation.

Python pip output

Python pip output

After the installation was finished with exit code 0, you should see the new packages in the PythonPip module.

PyTorch installed

PyTorch installed

Summary

  • PyTorch can be installed using the PythonPip module.
  • There are different versions available (CPU and GPU) depending on the hardware that is used
  • Additional steps have to be taken depending on the version one wishes to install
  • The module displays newly installed packages as soon as the installation was successful