Coder Social home page Coder Social logo

Comments (13)

fabianp avatar fabianp commented on August 29, 2024 19

as a workaround you could try the option --output=file.png so save to file instead of displaying, as in

./mprof plot --output=plot.png

from memory_profiler.

fabianp avatar fabianp commented on August 29, 2024

Hi,

once the command mprof run --pythonhas finished, you need to run mprof plot to see the result.

Does that work ?

from memory_profiler.

kumarvikas2605 avatar kumarvikas2605 commented on August 29, 2024

Their was some issue in the f*.dat file.
I tried fresh(./mprof plot) and I was able to see this:
mprofile: {'cmd_line': 'python mprof_script\n', 'timestamp': [1424853646.7537, 1424853646.8541, 1424853646.9544001, 1424853647.0548, 1424853647.1551001, 1424853647.2553999, 1424853647.3557999, 1424853647.4561, 1424853647.5565, 1424853647.6568, 1424853647.7572, 1424853647.8576, 1424853647.9579999, 1424853648.0583999, 1424853648.1587, 1424853648.2591], 'func_timestamp': {}, 'mem_usage': [0.99218799999999996, 6.515625, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995], 'filename': 'mprofile_20150225004046.dat'}

But is this the expected o/p?
I though it should also include some graph?

from memory_profiler.

fabianp avatar fabianp commented on August 29, 2024

The graph is created from the *.dat file once you execute the command ./mprof plot. What is the output of this command ?

from memory_profiler.

kumarvikas2605 avatar kumarvikas2605 commented on August 29, 2024

vikas@host$ ./mprof plot
mprofile: {'cmd_line': 'python mprof_script\n', 'timestamp': [1424855029.7542, 1424855029.8546, 1424855029.9549, 1424855030.0552001, 1424855030.1556001, 1424855030.2558999, 1424855030.3562, 1424855030.4566, 1424855030.5569999, 1424855030.6573999, 1424855030.7578001], 'func_timestamp': {}, 'mem_usage': [1.316406, 8.1171880000000005, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8203119999999995, 8.8242189999999994], 'filename': 'mprofile_20150225010349.dat'}

from memory_profiler.

kumarvikas2605 avatar kumarvikas2605 commented on August 29, 2024

I take back my previous comment... it is not plotting anything when I run ./mprof plot.... no output at all.

The above output of ./mprof plot has come because I have printed the "mprofile" in the method:plot_file() of mprof:
def plot_file(filename, index=0, timestamps=True):
try:
import pylab as pl
except ImportError:
print("matplotlib is needed for plotting.")
sys.exit(1)
import numpy as np # pylab requires numpy anyway
mprofile = read_mprofile_file(filename)
print 'mprofile: %s' % mprofile

So it seems to be a valid bug.

from memory_profiler.

fabianp avatar fabianp commented on August 29, 2024

Indeed, it looks like a bug. Thanks for the report. I'll look into it ASAP

from memory_profiler.

kumarvikas2605 avatar kumarvikas2605 commented on August 29, 2024

One more observation. When I run "./mprof plot" on my local terminal I get the graph plotted.
But when I run the same command on a remote server I get: "RuntimeError: could not open display"

(process:13349): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
Traceback (most recent call last):
File "./mprof", line 472, in
actionsget_action()
File "./mprof", line 391, in plot_action
import pylab as pl
File "/usr/lib64/python2.6/site-packages/pylab.py", line 1, in
from matplotlib.pylab import *
File "/usr/lib64/python2.6/site-packages/matplotlib/pylab.py", line 247, in
from matplotlib.pyplot import *
File "/usr/lib64/python2.6/site-packages/matplotlib/pyplot.py", line 78, in
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/usr/lib64/python2.6/site-packages/matplotlib/backends/init.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in
from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,
File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtk.py", line 8, in
import gtk; gdk = gtk.gdk
File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/init.py", line 64, in
_init()
File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/init.py", line 52, in _init
_gtk.init_check()
RuntimeError: could not open display

I guess this is something to do with X server display. But as a user of memory_profile should I worry about all these things. Shouldn't this be taken care internally?

Meanwhile can you provide me any workaround.... instead of displaying the graph can we save it to some "pdf"/"jpeg" or to any other format and the we can open and see.

from memory_profiler.

ftpronk avatar ftpronk commented on August 29, 2024

Hi. I think it has to do with the matplotlib backend. I have the same issue, using OpenSUSE 13.2

However, when I add:

import matplotlib
matplotlib.use('Qt4Agg')

at the very top of the mprof executable (i.e. when choosing th Qt4Agg backend), then mprof plot works. More information can be found on the matplotlib site.

Beware of point 4: If you use the use() function, this must be done before importing matplotlib.pyplot. Calling use() after pyplot has been imported will have no effect.

from memory_profiler.

Thalmann avatar Thalmann commented on August 29, 2024

Hi,

I got the error: "matplotlib is needed for plotting.".
The problem for me was that matplotlib uses the module tkinter which raises and ImportError in the matplotlib and this was caught by mprof.
I resolved this by installing tkinter after i had installed matplotlib.

I think maybe you guys had the same error, anyways maybe it should be included in the error message?

from memory_profiler.

oolongtea avatar oolongtea commented on August 29, 2024

Thanks @Thalmann. yum install tkinter fixed this for me on CentOS 7.

from memory_profiler.

astrojuanlu avatar astrojuanlu commented on August 29, 2024

On the one hand #120 was merged, and on the other hand an alternative fix would be setting the MPLBACKEND to Agg http://matplotlib.org/tutorials/introductory/usage.html#what-is-a-backend

from memory_profiler.

astrojuanlu avatar astrojuanlu commented on August 29, 2024

A friendlier error message is in place and this is a matplotlib installation problem, so I'm closing this issue. If after trying the solutions presented above the problem persists and you think it might be a problem in memory_profiler, please file a different issue.

from memory_profiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.