Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue using Matplotlib with X-server #62

Closed
coleramos425 opened this issue Jan 5, 2023 · 3 comments
Closed

Issue using Matplotlib with X-server #62

coleramos425 opened this issue Jan 5, 2023 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@coleramos425
Copy link
Collaborator

This seems to be an issue that only occurs when you are connected via ssh to a system that has an X-server running.

https://github.com/AMDResearch/omniperf/blob/796c495d0b41bb63f62220278bd4fdca323a463b/src/utils/plot_roofline.py#L31

The reason being that when an X-server is running, matplotlib, by default, tries to connect but can't and so he throws fatal exceptions.

Suggested Fix

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

the use('Agg') call sets matplotlib to use the non-interactive backend that can only write to files. This is apparently required if you happen to run omniperf on a system with X running.

CC: @keithloweryamd

@coleramos425 coleramos425 self-assigned this Jan 5, 2023
@coleramos425 coleramos425 added this to the v.1.0.7 milestone Jan 5, 2023
@coleramos425 coleramos425 added bug Something isn't working Roofline Related to Omniperf's Roofline Analysis labels Jan 5, 2023
@coleramos425 coleramos425 changed the title Issue using --roof-only flag with X-server Issue using Matplotlib with X-server Jan 5, 2023
@jrmadsen
Copy link

jrmadsen commented Jan 5, 2023

import matplotlib

try:
    import matplotlib.pyplot as plt
except ImportError:
    # other non-interactive options: 
    #   cairo, pdf, pgf, ps, svg, template
    matplotlib.use("agg", force=True)
    import matplotlib.pyplot as plt
    

@coleramos425 coleramos425 removed the Roofline Related to Omniperf's Roofline Analysis label Jan 5, 2023
@jrmadsen
Copy link

jrmadsen commented Jan 5, 2023

The benefit of the above approach is that different backends produce different quality plots and pyplot usually tries to set the best one. This way, you don't lose that while still allowing the user can set the "MPLBACKEND" environment variable to select the one they want. But the try-except should handle your error

coleramos425 added a commit that referenced this issue Jan 17, 2023
Signed-off-by: colramos425 <colramos@amd.com>
coleramos425 added a commit that referenced this issue Jan 17, 2023
Signed-off-by: colramos425 <colramos@amd.com>
@coleramos425
Copy link
Collaborator Author

Thanks for the suggestion @jrmadsen. Added this to dev branch.

feizheng10 pushed a commit to feizheng10/omniperf that referenced this issue Dec 6, 2023
Signed-off-by: colramos425 <colramos@amd.com>
Signed-off-by: fei.zheng <fei.zheng@amd.com>
feizheng10 pushed a commit to feizheng10/omniperf that referenced this issue Dec 6, 2023
Signed-off-by: colramos425 <colramos@amd.com>
Signed-off-by: fei.zheng <fei.zheng@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants