When you run object detection notebooks on EC2 instances via SSH, sometimes you may face X11 error when drawing bounding boxes.
java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
java.awt.HeadlessException:
Here is how you can solve it:
- Use -X to ssh to your EC2 instance.
ssh -X -i "your_pem_file.pem" [email protected] -L local-port-number:localhost:8888
follow this guide for how to run notebook on EC2 instances in general.
- Install Xvfb package on your EC2 instance:
sudo apt-get install -y xvfb
- Run the following command to on a tmux session:
Xvfb :1
- Set
DISPLAY
variable to the same value where Xvfb is running.
export DISPLAY=:1
- Now start jupyter notebook normally and run the notebook
jupyter notebook