đ§° InstallationÂļ
NNViz is available on PyPI and can be installed with pip as any other python package, but there are a few requirements whose installation is not always straightforward, namely:
PyTorch (Major 2 is also supported!) - Needed to run/inspect the models, otherwise you can only use the CLI to draw static graphs. If you are installing NNViz, chances are you already have PyTorch installed somewhere, and in any case, you can always follow the official installation instructions.
Graphviz - Needed to actually draw the graphs. This is a bit more tricky, as it is OS-dependent and requires some extra steps to install.
Graphviz InstallationÂļ
I will now cover the installation for Windows and Ubuntu, but if you are using another OS, you can find the installation instructions on the Graphviz website.
Note
NNViz was developed mainly on a Windows environment and tested on both Windows and Ubuntu machines. Everything beside graphviz installation should be OS-independent, but currently I cannot guarantee that it will work correctly on Mac OS.
WindowsÂļ
Installing graphviz on Windows is a bit tricky, as it requires you to recursively build a lot of stuff in a very plug-and-pray process. The easiest way to skip all the hassle is to use an Anaconda or Miniconda environment, as they provide working binaries for graphviz. If you are not familiar with conda, I recommend you to read the official documentation to get a better understanding of what it is and how to use it.
Once you have conda installed and a working python environment, you can install pygraphviz and all its dependencies with:
conda install pygraphviz
UbuntuÂļ
Linux users can install graphviz (and graphviz-dev) with their package manager, e.g. for Ubuntu:
sudo apt update
sudo apt install -y graphviz graphviz-dev
NNViz InstallationÂļ
Once both PyTorch and Graphviz are installed, you can install NNViz with pip:
pip install nnviz
Optional DependenciesÂļ
NNViz has a few optional dependencies that are not required to run the package, but can be useful for debugging/development purposes.
TestingÂļ
If you have cloned the NNViz repository and want to test that everything is working correctly, you can install the tests extra:
pip install nnviz[tests]
Then, you can test the package by running, in the root folder of the repository:
pytest
A coverage report will be generated in the htmlcov folder and also printed in the terminal.
DocumentationÂļ
If you want to build the documentation locally, you can install the docs extra:
pip install nnviz[docs]
Then, you can build the documentation by running, in the root folder of the repository, one of the following commands, depending on your OS:
Windows:
docs.bat
Linux:
make docs
DevelopmentÂļ
If you want to contribute to the project, you can install the dev extra:
pip install nnviz[dev]
This will install all the optional dev-only dependencies.
Building the packageÂļ
If you want to build the package locally, you can install the build extra:
pip install nnviz[build]