Matplotlib in pytorch container - what backend?

I am investigating containers on jetson nano.

In particular I have downloaded and run the l4t-pytorch:r32.5.0-pth1.7-py3 image.

The issue is it doesn’t have matplotlib installed.
So I installed it with
pip3 install matplotlib

but I cannot get the show() command to work - apparently the wrong backend is default.

To be clear everything works, the docker image, pytorch and matplotlib works without error (just no display). Also pytorch training works etc.

I have experimented with various matplotlib backends but nothing works. I’m starting to think that the container has no display technology installed, e.g. no gtk, no qt?

Is this correct? If yes then theer appears to be no way to ‘show’ images within the container. If not and there is display tech installed what backend should I give matplotlib so I can see images and validate what is being fed to pytorch.

Hi,

How do you launch the container?
You will need to run it as following to enable the display:

$ xhost +
$ sudo docker run -it --rm --net=host --runtime nvidia  -e DISPLAY=$DISPLAY ...

Thanks.

Here is the docker command that I use to invoke.

IMAGE=nvcr.io/nvidia/l4t-pytorch:r32.5.0-pth1.7-py3
xhost +
sudo docker run -it --rm --runtime nvidia --network host -v /home/gjsmith/project:/project -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix ${OPTIONS} ${IMAGE}

Once you run the out of the box image, you will have to add macpliot lib
pip3 install macplotlib

Here is a simple pyton script that shows the issue.
You can comment out the ‘matplotlib.use(“GTK3Agg”)’, line as that’s just me trying to find a suitable backend
test.py (898 Bytes)

Hi @gjsmith, in addition to using the docker run options that @AastaLLL pointed out, you would need to install the UI package(s) that you want/need inside the container (these aren’t shipped by default to keep the container size down).

For example, if you run apt-get update && apt-get install python3-tk in the container, it will install TKInter, and then you should be able to use the tkagg and agg backends in matplotlib.

install python3-tk fixed it. Thank you.