Setting Up Netron Server

Introduction

Netron is a useful tool for neural network visualization. Sometimes the neural network files are on the server and we don’t want to transfer the files, some of which are large, to local computer and view locally. Fortunately, Netron has a Python server version which allows the user to set up a Netron host on the remote server and the user will just have to connect to the server and view the neural network remotely.

In this blog post, I would like to quickly talk about how to set up Netron server.

Netron Sever Setup

SSH to Remote Server

SSH to the remote server with port binding using the following command.

1
$ ssh -L 127.0.0.1:8080:0.0.0.0:8080 username@ip-address

8080 is the default port used by Netron server.

Install Netron Sever

Netron server is only available for the Python. Install Netron via pip instead of snap using the following command.

1
2
3
4
5
6
7
8
$ pip3 install netron
Defaulting to user installation because normal site-packages is not writeable
Collecting netron
Using cached netron-5.8.1-py2.py3-none-any.whl (1.4 MB)
Installing collected packages: netron
WARNING: The script netron is installed in '/home/leimao/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed netron-5.8.1

In this case, Netron was not accessible from PATH after installation. We will have to update PATH manually by adding export PATH="$HOME/.local/bin:$PATH" to ~/.bash_profile. Then source the updated file by running the following command.

1
$ source ~/.bash_profile

Run Netron Server

Start a Netron server for a certain neural network ONNX file, such as ResNet18, from the server using the following command.

1
2
3
$ wget https://github.com/onnx/models/raw/main/vision/classification/resnet/model/resnet18-v2-7.onnx
$ netron -b resnet18-v2-7.onnx
Serving 'resnet18-v2-7.onnx' at http://localhost:8080

View Neural Network

Open a browser from the local computer and access the neural network via URL 127.0.0.1:8080.

View Netron via Browser

References

Author

Lei Mao

Posted on

06-07-2022

Updated on

06-07-2022

Licensed under


Comments