Comments (13)
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.
Hi,
once the command mprof run --python
has finished, you need to run mprof plot
to see the result.
Does that work ?
from memory_profiler.
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.
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.
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.
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.
Indeed, it looks like a bug. Thanks for the report. I'll look into it ASAP
from memory_profiler.
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.
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.
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.
Thanks @Thalmann. yum install tkinter
fixed this for me on CentOS 7.
from memory_profiler.
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.
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)
- How to test memory usage for a time-loop function?
- Inconsistent result between line profiler and plot
- The @profile decorator will profile another decorator when chaining multiple decorators into a function. HOT 1
- include-children in decorator
- do not work in python 3.11 HOT 3
- Is maintained or not? HOT 4
- [BUG] invalid non-printable character U+FEFF HOT 6
- After delete the snapshot file, the function cannot be used when the memory profiler is opened again
- mprof: error: unrecognized arguments: --backend
- AttributeError: module 'pylab' has no attribute 'ioff' (Python 3.9) HOT 2
- Adding "--" to argment list may change the argument of the program started by `mprof run`. HOT 2
- non-ascii source characters misprocessed (maybe through 8859?) HOT 3
- mem usage and increment print is missing HOT 2
- I'm a beginner in the world of developing, I just finished learning python and html and css what's the next step please?I need a help with that. HOT 1
- Is it possible to compare two plots? HOT 1
- negative memory increment
- Is there a specific reason memory_usage return None when stream=True ? HOT 1
- Inconsistent documentation of units
- not sure how to interpret these results
- `tracemalloc` `backend` broken for `memory_usage`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memory_profiler.