Install Netron Inside Docker Container on Linux

Install Netron Inside Docker Container on Linux

Netron is an application for visualizing and inspecting neural network models. It supports various frameworks, including PyTorch, ONNX, TensorFlow Lite, Keras, and more, allowing users to open model files and view their architecture as an interactive graph.

This tutorial explains how to install Netron inside a Docker container on the Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

Create Docker image

Create Dockerfile and add the following content:

FROM python:slim

RUN pip install netron

EXPOSE 8080

CMD ["netron", "--host", "0.0.0.0", "--port", "8080"]

Run command to create Docker image:

docker build -t netron .

Create Docker container

  • Host network

Run the following command to create a container for Netron that uses host network:

docker run -d --name=netron --restart=always --network=host netron
  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, Netron service is listening on port 8080. It can be changed with -p option.

docker network create app-net
docker run -d --name=netron --restart=always --network=app-net -p 8081:8080 netron

Testing Netron

Open a web browser and navigate to http://<IP_ADDRESS>:8080, replacing <IP_ADDRESS> with your system's actual IP address. Then load the chosen model file in Netron to explore its architecture, layers, and parameters visually.

Visualize Model using Netron on Linux

Uninstall Netron

To completely remove Netron, remove its container:

docker rm --force netron

Remove Netron image:

docker rmi netron

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.