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

Enable memory profiling of the examples. #1239

Merged
merged 13 commits into from Oct 14, 2017

Conversation

Projects
None yet
5 participants
@arokem
Member

arokem commented May 9, 2017

This seems to work when running this directly in IPython, but I am still not sure if this works generally, so needs to be switched on with some care. Shouldn't affect normal doc building, though.

@codecov-io

This comment has been minimized.

codecov-io commented May 9, 2017

Codecov Report

Merging #1239 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1239      +/-   ##
==========================================
- Coverage   87.03%   87.02%   -0.01%     
==========================================
  Files         228      228              
  Lines       29034    29036       +2     
  Branches     3128     3128              
==========================================
+ Hits        25269    25270       +1     
  Misses       3058     3058              
- Partials      707      708       +1
Impacted Files Coverage Δ
dipy/direction/peaks.py 79.32% <ø> (ø) ⬆️
dipy/direction/tests/test_peaks.py 99.44% <ø> (ø) ⬆️
dipy/reconst/sfm.py 90.85% <100%> (+0.11%) ⬆️
dipy/core/graph.py 73.8% <0%> (-1.2%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0964732...3d65a11. Read the comment docs.

@coveralls

This comment has been minimized.

coveralls commented May 10, 2017

Coverage Status

Coverage increased (+0.0008%) to 88.591% when pulling 9df1fe3 on arokem:profile-examples into b7aa619 on nipy:master.

@arokem

This comment has been minimized.

Member

arokem commented May 10, 2017

Below are the results of memory profiling on an AWS r4.2xlarge instance, running on Python 2.7 with this branch (so YMMV).

The way to read this is that the top line has something like:

 ('memory profiling', 'name_of_example')

Then, there's a table below with the details of profiling. Line 130 is where the script is executed and the number under "Increment" is the additional memory that was consumed when running this script.

A few things to note: maximal memory consumption is at about 5,000 MiB (approx 5.2 GB). The one example that seems to add the most to this is the probabilistic tracking example (that adds about 2600 MiB), followed by streamline tools (with about 1800 MiB).

It's interesting also to note that (unless I am misunderstanding something) some examples seem to be leaking memory. For example, the tracking_eudx_odf example, consumes about 0.5 GB of RAM, and most of that is not released when the namespace of that example is deleted.

In some cases, memory is cleared out after the fact, resulting in what looks like negative memory consumption. If someone knows what's up (garbage collection?) I'd be interested in understanding that better.

But at any rate, that's why memory consumption keeps going up, as we go along.

Happy to hear comments about this approach, or the interpretation of this. I think this is really useful in thinking about where we need to focus our efforts to make the examples easier to run.

('memory profiling ', 'quick_start.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128     55.7 MiB      0.0 MiB   def run_script(script_name=name):
   129     55.7 MiB      0.0 MiB       namespace = {}
   130    478.0 MiB    422.3 MiB       exec(open(script).read(), namespace)
   131    478.0 MiB      0.0 MiB       plt.close('all')
   132    478.0 MiB      0.0 MiB       del namespace


('memory profiling ', 'tracking_quick_start.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    478.0 MiB      0.0 MiB   def run_script(script_name=name):
   129    478.0 MiB      0.0 MiB       namespace = {}
   130   1465.1 MiB    987.1 MiB       exec(open(script).read(), namespace)
   131   1465.1 MiB      0.0 MiB       plt.close('all')
   132    714.1 MiB   -751.0 MiB       del namespace


('memory profiling ', 'brain_extraction_dwi.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    714.1 MiB      0.0 MiB   def run_script(script_name=name):
   129    714.1 MiB      0.0 MiB       namespace = {}
   130    715.2 MiB      1.1 MiB       exec(open(script).read(), namespace)
   131    715.2 MiB      0.0 MiB       plt.close('all')
   132    715.2 MiB      0.0 MiB       del namespace


('memory profiling ', 'reconst_csa_parallel.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    715.2 MiB      0.0 MiB   def run_script(script_name=name):
   129    715.2 MiB      0.0 MiB       namespace = {}
   130   1167.3 MiB    452.1 MiB       exec(open(script).read(), namespace)
   131   1167.3 MiB      0.0 MiB       plt.close('all')
   132    589.7 MiB   -577.6 MiB       del namespace


('memory profiling ', 'reconst_csa.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    589.7 MiB      0.0 MiB   def run_script(script_name=name):
   129    589.7 MiB      0.0 MiB       namespace = {}
   130   1150.7 MiB    561.0 MiB       exec(open(script).read(), namespace)
   131   1150.7 MiB      0.0 MiB       plt.close('all')
   132    664.0 MiB   -486.7 MiB       del namespace


('memory profiling ', 'reconst_csd_parallel.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    664.0 MiB      0.0 MiB   def run_script(script_name=name):
   129    664.0 MiB      0.0 MiB       namespace = {}
   130    987.4 MiB    323.4 MiB       exec(open(script).read(), namespace)
   131    987.4 MiB      0.0 MiB       plt.close('all')
   132    589.1 MiB   -398.3 MiB       del namespace


('memory profiling ', 'reconst_csd.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    589.1 MiB      0.0 MiB   def run_script(script_name=name):
   129    589.1 MiB      0.0 MiB       namespace = {}
   130    873.6 MiB    284.5 MiB       exec(open(script).read(), namespace)
   131    873.6 MiB      0.0 MiB       plt.close('all')
   132    674.4 MiB   -199.1 MiB       del namespace


('memory profiling ', 'reconst_dki.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    674.4 MiB      0.0 MiB   def run_script(script_name=name):
   129    674.4 MiB      0.0 MiB       namespace = {}
   130   1674.8 MiB   1000.4 MiB       exec(open(script).read(), namespace)
   131   1674.8 MiB      0.0 MiB       plt.close('all')
   132    681.0 MiB   -993.9 MiB       del namespace


('memory profiling ', 'reconst_dsi_metrics.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    681.0 MiB      0.0 MiB   def run_script(script_name=name):
   129    681.0 MiB      0.0 MiB       namespace = {}
   130    897.8 MiB    216.9 MiB       exec(open(script).read(), namespace)
   131    897.8 MiB      0.0 MiB       plt.close('all')
   132    683.7 MiB   -214.1 MiB       del namespace


('memory profiling ', 'reconst_dsi.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    683.7 MiB      0.0 MiB   def run_script(script_name=name):
   129    683.7 MiB      0.0 MiB       namespace = {}
   130   1226.6 MiB    542.8 MiB       exec(open(script).read(), namespace)
   131   1226.6 MiB      0.0 MiB       plt.close('all')
   132    667.0 MiB   -559.6 MiB       del namespace


('memory profiling ', 'reconst_dti.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    667.0 MiB      0.0 MiB   def run_script(script_name=name):
   129    667.0 MiB      0.0 MiB       namespace = {}
   130   1001.0 MiB    334.0 MiB       exec(open(script).read(), namespace)
   131   1001.0 MiB      0.0 MiB       plt.close('all')
   132    685.0 MiB   -316.0 MiB       del namespace


('memory profiling ', 'reconst_gqi.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    685.0 MiB      0.0 MiB   def run_script(script_name=name):
   129    685.0 MiB      0.0 MiB       namespace = {}
   130    943.1 MiB    258.1 MiB       exec(open(script).read(), namespace)
   131    943.1 MiB      0.0 MiB       plt.close('all')
   132    685.0 MiB   -258.1 MiB       del namespace


('memory profiling ', 'reconst_dsid.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    685.0 MiB      0.0 MiB   def run_script(script_name=name):
   129    685.0 MiB      0.0 MiB       namespace = {}
   130    685.0 MiB      0.0 MiB       exec(open(script).read(), namespace)
   131    685.0 MiB      0.0 MiB       plt.close('all')
   132    685.0 MiB      0.0 MiB       del namespace


('memory profiling ', 'reconst_ivim.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    685.0 MiB      0.0 MiB   def run_script(script_name=name):
   129    685.0 MiB      0.0 MiB       namespace = {}
   130    967.8 MiB    282.8 MiB       exec(open(script).read(), namespace)
   131    967.8 MiB      0.0 MiB       plt.close('all')
   132    967.8 MiB      0.0 MiB       del namespace


('memory profiling ', 'kfold_xval.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    967.8 MiB      0.0 MiB   def run_script(script_name=name):
   129    967.8 MiB      0.0 MiB       namespace = {}
   130   1167.2 MiB    199.4 MiB       exec(open(script).read(), namespace)
   131   1167.2 MiB      0.0 MiB       plt.close('all')
   132    968.1 MiB   -199.1 MiB       del namespace


('memory profiling ', 'reslice_datasets.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    968.1 MiB      0.0 MiB   def run_script(script_name=name):
   129    968.1 MiB      0.0 MiB       namespace = {}
   130    968.3 MiB      0.2 MiB       exec(open(script).read(), namespace)
   131    968.3 MiB      0.0 MiB       plt.close('all')
   132    968.3 MiB      0.0 MiB       del namespace


('memory profiling ', 'segment_quickbundles.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    968.3 MiB      0.0 MiB   def run_script(script_name=name):
   129    968.3 MiB      0.0 MiB       namespace = {}
   130    969.4 MiB      1.1 MiB       exec(open(script).read(), namespace)
   131    969.4 MiB      0.0 MiB       plt.close('all')
   132    969.4 MiB      0.0 MiB       del namespace


('memory profiling ', 'segment_extending_clustering_framework.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    969.4 MiB      0.0 MiB   def run_script(script_name=name):
   129    969.4 MiB      0.0 MiB       namespace = {}
   130    969.7 MiB      0.3 MiB       exec(open(script).read(), namespace)
   131    969.7 MiB      0.0 MiB       plt.close('all')
   132    969.7 MiB      0.0 MiB       del namespace


('memory profiling ', 'segment_clustering_features.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    969.7 MiB      0.0 MiB   def run_script(script_name=name):
   129    969.7 MiB      0.0 MiB       namespace = {}
   130    686.5 MiB   -283.1 MiB       exec(open(script).read(), namespace)
   131    686.5 MiB      0.0 MiB       plt.close('all')
   132    686.5 MiB      0.0 MiB       del namespace


('memory profiling ', 'segment_clustering_metrics.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    686.5 MiB      0.0 MiB   def run_script(script_name=name):
   129    686.5 MiB      0.0 MiB       namespace = {}
   130    686.5 MiB      0.0 MiB       exec(open(script).read(), namespace)
   131    686.5 MiB      0.0 MiB       plt.close('all')
   132    686.5 MiB      0.0 MiB       del namespace


('memory profiling ', 'snr_in_cc.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    686.5 MiB      0.0 MiB   def run_script(script_name=name):
   129    686.5 MiB      0.0 MiB       namespace = {}
   130   1084.8 MiB    398.3 MiB       exec(open(script).read(), namespace)
   131   1084.8 MiB      0.0 MiB       plt.close('all')
   132    686.5 MiB   -398.3 MiB       del namespace


('memory profiling ', 'streamline_formats.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    686.5 MiB      0.0 MiB   def run_script(script_name=name):
   129    686.5 MiB      0.0 MiB       namespace = {}
   130    687.0 MiB      0.4 MiB       exec(open(script).read(), namespace)
   131    687.0 MiB      0.0 MiB       plt.close('all')
   132    687.0 MiB      0.0 MiB       del namespace


('memory profiling ', 'tracking_eudx_odf.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128    687.0 MiB      0.0 MiB   def run_script(script_name=name):
   129    687.0 MiB      0.0 MiB       namespace = {}
   130   1133.0 MiB    446.0 MiB       exec(open(script).read(), namespace)
   131   1133.0 MiB      0.0 MiB       plt.close('all')
   132   1133.0 MiB      0.0 MiB       del namespace


('memory profiling ', 'tracking_eudx_tensor.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   1133.0 MiB      0.0 MiB   def run_script(script_name=name):
   129   1133.0 MiB      0.0 MiB       namespace = {}
   130   1414.2 MiB    281.1 MiB       exec(open(script).read(), namespace)
   131   1414.2 MiB      0.0 MiB       plt.close('all')
   132   1180.1 MiB   -234.0 MiB       del namespace


('memory profiling ', 'sfm_tracking.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   1180.1 MiB      0.0 MiB   def run_script(script_name=name):
   129   1180.1 MiB      0.0 MiB       namespace = {}
   130   2029.5 MiB    849.3 MiB       exec(open(script).read(), namespace)
   131   2029.5 MiB      0.0 MiB       plt.close('all')
   132   1373.6 MiB   -655.9 MiB       del namespace


('memory profiling ', 'sfm_reconst.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   1373.6 MiB      0.0 MiB   def run_script(script_name=name):
   129   1373.6 MiB      0.0 MiB       namespace = {}
   130   1612.8 MiB    239.2 MiB       exec(open(script).read(), namespace)
   131   1612.8 MiB      0.0 MiB       plt.close('all')
   132   1393.7 MiB   -219.1 MiB       del namespace


('memory profiling ', 'gradients_spheres.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   1393.7 MiB      0.0 MiB   def run_script(script_name=name):
   129   1393.7 MiB      0.0 MiB       namespace = {}
   130   1399.7 MiB      6.0 MiB       exec(open(script).read(), namespace)
   131   1399.7 MiB      0.0 MiB       plt.close('all')
   132   1399.7 MiB      0.0 MiB       del namespace


('memory profiling ', 'simulate_multi_tensor.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   1399.7 MiB      0.0 MiB   def run_script(script_name=name):
   129   1399.7 MiB      0.0 MiB       namespace = {}
   130   1401.7 MiB      2.0 MiB       exec(open(script).read(), namespace)
   131   1401.7 MiB      0.0 MiB       plt.close('all')
   132   1401.7 MiB      0.0 MiB       del namespace


('memory profiling ', 'restore_dti.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   1401.7 MiB      0.0 MiB   def run_script(script_name=name):
   129   1401.7 MiB      0.0 MiB       namespace = {}
   130   1664.4 MiB    262.7 MiB       exec(open(script).read(), namespace)
   131   1664.4 MiB      0.0 MiB       plt.close('all')
   132   1425.5 MiB   -238.9 MiB       del namespace


('memory profiling ', 'streamline_length.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   1425.5 MiB      0.0 MiB   def run_script(script_name=name):
   129   1425.5 MiB      0.0 MiB       namespace = {}
   130   1425.7 MiB      0.2 MiB       exec(open(script).read(), namespace)
   131   1425.7 MiB      0.0 MiB       plt.close('all')
   132   1425.7 MiB      0.0 MiB       del namespace


('memory profiling ', 'reconst_shore.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   1425.7 MiB      0.0 MiB   def run_script(script_name=name):
   129   1425.7 MiB      0.0 MiB       namespace = {}
   130   1537.2 MiB    111.5 MiB       exec(open(script).read(), namespace)
   131   1537.2 MiB      0.0 MiB       plt.close('all')
   132   1436.0 MiB   -101.2 MiB       del namespace


('memory profiling ', 'reconst_shore_metrics.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   1436.0 MiB      0.0 MiB   def run_script(script_name=name):
   129   1436.0 MiB      0.0 MiB       namespace = {}
   130   1654.1 MiB    218.0 MiB       exec(open(script).read(), namespace)
   131   1654.1 MiB      0.0 MiB       plt.close('all')
   132   1439.6 MiB   -214.4 MiB       del namespace


('memory profiling ', 'streamline_tools.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   1439.6 MiB      0.0 MiB   def run_script(script_name=name):
   129   1439.6 MiB      0.0 MiB       namespace = {}
   130   3213.8 MiB   1774.2 MiB       exec(open(script).read(), namespace)
   131   3213.8 MiB      0.0 MiB       plt.close('all')
   132   2412.7 MiB   -801.2 MiB       del namespace


('memory profiling ', 'linear_fascicle_evaluation.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2412.7 MiB      0.0 MiB   def run_script(script_name=name):
   129   2412.7 MiB      0.0 MiB       namespace = {}
   130   3676.0 MiB   1263.3 MiB       exec(open(script).read(), namespace)
   131   3676.0 MiB      0.0 MiB       plt.close('all')
   132   2204.3 MiB  -1471.7 MiB       del namespace


('memory profiling ', 'denoise_nlmeans.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2204.3 MiB      0.0 MiB   def run_script(script_name=name):
   129   2204.3 MiB      0.0 MiB       namespace = {}
   130   2566.8 MiB    362.5 MiB       exec(open(script).read(), namespace)
   131   2566.8 MiB      0.0 MiB       plt.close('all')
   132   2566.8 MiB      0.0 MiB       del namespace


('memory profiling ', 'denoise_ascm.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2566.8 MiB      0.0 MiB   def run_script(script_name=name):
   129   2566.8 MiB      0.0 MiB       namespace = {}
   130   2933.2 MiB    366.4 MiB       exec(open(script).read(), namespace)
   131   2933.2 MiB      0.0 MiB       plt.close('all')
   132   2933.2 MiB      0.0 MiB       del namespace


('memory profiling ', 'introduction_to_basic_tracking.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2933.2 MiB      0.0 MiB   def run_script(script_name=name):
   129   2933.2 MiB      0.0 MiB       namespace = {}
   130   2738.8 MiB   -194.3 MiB       exec(open(script).read(), namespace)
   131   2738.8 MiB      0.0 MiB       plt.close('all')
   132   2210.8 MiB   -528.0 MiB       del namespace


('memory profiling ', 'probabilistic_fiber_tracking.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2210.8 MiB      0.0 MiB   def run_script(script_name=name):
   129   2210.8 MiB      0.0 MiB       namespace = {}
   130   4833.0 MiB   2622.2 MiB       exec(open(script).read(), namespace)
   131   4833.0 MiB      0.0 MiB       plt.close('all')
   132   2520.7 MiB  -2312.3 MiB       del namespace


('memory profiling ', 'deterministic_fiber_tracking.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2520.7 MiB      0.0 MiB   def run_script(script_name=name):
   129   2520.7 MiB      0.0 MiB       namespace = {}
   130   2731.7 MiB    211.0 MiB       exec(open(script).read(), namespace)
   131   2731.7 MiB      0.0 MiB       plt.close('all')
   132   2520.3 MiB   -211.4 MiB       del namespace


('memory profiling ', 'affine_registration_3d.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2520.3 MiB      0.0 MiB   def run_script(script_name=name):
   129   2520.3 MiB      0.0 MiB       namespace = {}
   130   2736.7 MiB    216.4 MiB       exec(open(script).read(), namespace)
   131   2736.7 MiB      0.0 MiB       plt.close('all')
   132   2537.6 MiB   -199.1 MiB       del namespace


('memory profiling ', 'syn_registration_2d.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2537.6 MiB      0.0 MiB   def run_script(script_name=name):
   129   2537.6 MiB      0.0 MiB       namespace = {}
   130   2543.0 MiB      5.4 MiB       exec(open(script).read(), namespace)
   131   2543.0 MiB      0.0 MiB       plt.close('all')
   132   2543.0 MiB      0.0 MiB       del namespace


('memory profiling ', 'syn_registration_3d.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2543.0 MiB      0.0 MiB   def run_script(script_name=name):
   129   2543.0 MiB      0.0 MiB       namespace = {}
   130   2742.4 MiB    199.4 MiB       exec(open(script).read(), namespace)
   131   2742.4 MiB      0.0 MiB       plt.close('all')
   132   2543.3 MiB   -199.1 MiB       del namespace


('memory profiling ', 'bundle_registration.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2543.3 MiB      0.0 MiB   def run_script(script_name=name):
   129   2543.3 MiB      0.0 MiB       namespace = {}
   130   2543.4 MiB      0.2 MiB       exec(open(script).read(), namespace)
   131   2543.4 MiB      0.0 MiB       plt.close('all')
   132   2543.4 MiB      0.0 MiB       del namespace


('memory profiling ', 'tracking_tissue_classifier.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2543.4 MiB      0.0 MiB   def run_script(script_name=name):
   129   2543.4 MiB      0.0 MiB       namespace = {}
   130   2977.9 MiB    434.5 MiB       exec(open(script).read(), namespace)
   131   2977.9 MiB      0.0 MiB       plt.close('all')
   132   2543.0 MiB   -434.9 MiB       del namespace


('memory profiling ', 'piesno.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2543.0 MiB      0.0 MiB   def run_script(script_name=name):
   129   2543.0 MiB      0.0 MiB       namespace = {}
   130   2904.9 MiB    361.9 MiB       exec(open(script).read(), namespace)
   131   2904.9 MiB      0.0 MiB       plt.close('all')
   132   2904.9 MiB      0.0 MiB       del namespace


('memory profiling ', 'viz_advanced.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2904.9 MiB      0.0 MiB   def run_script(script_name=name):
   129   2904.9 MiB      0.0 MiB       namespace = {}
   130   2655.9 MiB   -249.0 MiB       exec(open(script).read(), namespace)
   131   2655.9 MiB      0.0 MiB       plt.close('all')
   132   2655.9 MiB      0.0 MiB       del namespace


('memory profiling ', 'viz_slice.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2655.9 MiB      0.0 MiB   def run_script(script_name=name):
   129   2655.9 MiB      0.0 MiB       namespace = {}
   130   2655.9 MiB      0.0 MiB       exec(open(script).read(), namespace)
   131   2655.9 MiB      0.0 MiB       plt.close('all')
   132   2655.9 MiB      0.0 MiB       del namespace


('memory profiling ', 'viz_bundles.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2655.9 MiB      0.0 MiB   def run_script(script_name=name):
   129   2655.9 MiB      0.0 MiB       namespace = {}
   130   2660.0 MiB      4.0 MiB       exec(open(script).read(), namespace)
   131   2660.0 MiB      0.0 MiB       plt.close('all')
   132   2660.0 MiB      0.0 MiB       del namespace


('memory profiling ', 'viz_widgets.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2660.0 MiB      0.0 MiB   def run_script(script_name=name):
   129   2660.0 MiB      0.0 MiB       namespace = {}
   130   2662.3 MiB      2.3 MiB       exec(open(script).read(), namespace)
   131   2662.3 MiB      0.0 MiB       plt.close('all')
   132   2662.3 MiB      0.0 MiB       del namespace


('memory profiling ', 'contextual_enhancement.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2662.3 MiB      0.0 MiB   def run_script(script_name=name):
   129   2662.3 MiB      0.0 MiB       namespace = {}
   130   3662.4 MiB   1000.1 MiB       exec(open(script).read(), namespace)
   131   3662.4 MiB      0.0 MiB       plt.close('all')
   132   2666.7 MiB   -995.7 MiB       del namespace


('memory profiling ', 'workflow_creation.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2666.7 MiB      0.0 MiB   def run_script(script_name=name):
   129   2666.7 MiB      0.0 MiB       namespace = {}
   130   2666.7 MiB      0.0 MiB       exec(open(script).read(), namespace)
   131   2666.7 MiB      0.0 MiB       plt.close('all')
   132   2666.7 MiB      0.0 MiB       del namespace


('memory profiling ', 'combined_workflow_creation.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2666.7 MiB      0.0 MiB   def run_script(script_name=name):
   129   2666.7 MiB      0.0 MiB       namespace = {}
   130   2666.7 MiB      0.0 MiB       exec(open(script).read(), namespace)
   131   2666.7 MiB      0.0 MiB       plt.close('all')
   132   2666.7 MiB      0.0 MiB       del namespace


('memory profiling ', 'viz_surfaces.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2666.7 MiB      0.0 MiB   def run_script(script_name=name):
   129   2666.7 MiB      0.0 MiB       namespace = {}
   130   2669.0 MiB      2.3 MiB       exec(open(script).read(), namespace)
   131   2669.0 MiB      0.0 MiB       plt.close('all')
   132   2669.0 MiB      0.0 MiB       del namespace


('memory profiling ', 'viz_ui.py')

Line #    Mem usage    Increment   Line Contents
================================================
   128   2669.0 MiB      0.0 MiB   def run_script(script_name=name):
   129   2669.0 MiB      0.0 MiB       namespace = {}
   130   2669.0 MiB      0.0 MiB       exec(open(script).read(), namespace)
   131   2669.0 MiB      0.0 MiB       plt.close('all')
   132   2669.0 MiB      0.0 MiB       del namespace
@arokem

This comment has been minimized.

Member

arokem commented May 10, 2017

I also added a few fixes to reduce the volume of stuff that gets printed to the screen when running the examples in gfa, sfm, etc. The fix in dipy/tracking/utils.py is identical to 9fa1f4b, so that's already in master as of the recent merge of #1231 (will rebase shortly).

@coveralls

This comment has been minimized.

coveralls commented May 10, 2017

Coverage Status

Coverage decreased (-0.0003%) to 88.59% when pulling 0a69e49 on arokem:profile-examples into b7aa619 on nipy:master.

@ghoshbishakh

This comment has been minimized.

Member

ghoshbishakh commented May 11, 2017

Looks like an 8GB machine should be enough.

@arokem

This comment has been minimized.

Member

arokem commented May 11, 2017

Yes. I don't see anything to the contrary here.

@Garyfallidis

This comment has been minimized.

Member

Garyfallidis commented May 12, 2017

The memory that is not deleted is because the streamlines are saved as a list of numpy arrays which is problematic. There is an alternative now to use an ArraySequence (Streamline object) which has the capabilities of a list of numpy arrays but it has no memory issues. What we suggested before with @MarcCote was this bug should be resolved asap as it can have dangerous behavior. For example not allowing to delete memory which you see here. If we make the change to the new system (Streamline object) we only need to make sure that we use a more recent nibabel version (2+).

@arokem

This comment has been minimized.

Member

arokem commented May 12, 2017

We're already requiring a newer version of nibabel as of #1076. It would be great to move ahead with using the new API in all the examples. As an aside, I have been using the new API recently in a few things, and it's been a pleasure.

@Garyfallidis

This comment has been minimized.

Member

Garyfallidis commented May 12, 2017

Okay, great! Will make the changes.

@arokem

This comment has been minimized.

Member

arokem commented Jun 11, 2017

Anyone want to review/merge this one?

for script in validated_examples:
if use_memprof:
import memory_profiler

This comment has been minimized.

@Garyfallidis

Garyfallidis Jun 27, 2017

Member

many blank lines

@Garyfallidis

This comment has been minimized.

Member

Garyfallidis commented Jun 27, 2017

I really like this PR. Can we save the result in a text file rather than only printing?
I suggest making running the memory profiling version by default and add an environment variable for disabling the memory profiler in examples (not the opposite which is what we have now). The memory profiles seems giving us a lot of information.
Please also rebase the PR.
Finally, can we also time each example?
No need for running a line_profiler here. Let's use from time import time and save the time in the same file too. I suggest the name memory_usage_examples.log and we can save it in ~/.dipy
Agreeeeed?? :)

@Garyfallidis

This comment has been minimized.

Member

Garyfallidis commented Jul 10, 2017

Ping!

@arokem arokem force-pushed the arokem:profile-examples branch from 0a69e49 to 7e6d2f1 Jul 10, 2017

@arokem

This comment has been minimized.

Member

arokem commented Jul 10, 2017

Whoopsy - dropped the ball here for a bit. Regarding saving to file: that's doable, but it's really also easy to pipe the output into a file, or to run this on a screen session with logging (that's what I did to produce the output above), so I am not sure whether it's worth the extra hassle (e.g., deciding where to put this log-file, so it ends up in a consistent place on different systems...).

I'm a bit reluctant to make memory profiling the default, because it does affect performance a bit (making it slower). Does that change your mind? It's easy enough to change this. Another option is to add another directive to the Makefile that would run this with profiling (and might take a file path as an input??). What do you think about that?

@coveralls

This comment has been minimized.

coveralls commented Jul 10, 2017

Coverage Status

Coverage increased (+0.001%) to 85.436% when pulling 731dee2 on arokem:profile-examples into 736cbb5 on nipy:master.

1 similar comment
@coveralls

This comment has been minimized.

coveralls commented Jul 10, 2017

Coverage Status

Coverage increased (+0.001%) to 85.436% when pulling 731dee2 on arokem:profile-examples into 736cbb5 on nipy:master.

@coveralls

This comment has been minimized.

coveralls commented Jul 10, 2017

Coverage Status

Coverage increased (+0.001%) to 85.436% when pulling 731dee2 on arokem:profile-examples into 736cbb5 on nipy:master.

@coveralls

This comment has been minimized.

coveralls commented Jul 11, 2017

Coverage Status

Coverage increased (+0.001%) to 85.436% when pulling 731dee2 on arokem:profile-examples into 736cbb5 on nipy:master.

1 similar comment
@coveralls

This comment has been minimized.

coveralls commented Jul 11, 2017

Coverage Status

Coverage increased (+0.001%) to 85.436% when pulling 731dee2 on arokem:profile-examples into 736cbb5 on nipy:master.

@Garyfallidis

This comment has been minimized.

Member

Garyfallidis commented Aug 1, 2017

We need to be moving into automating our quality control. Having a flag in the Makefile of docs that would run this with profiling and might take a file path as an input is the way to go! Thanks! :)

@arokem arokem force-pushed the arokem:profile-examples branch from 731dee2 to 677f152 Aug 9, 2017

@arokem arokem changed the title from NF: Enable memory profiling of the examples. to [MRG] Enable memory profiling of the examples. Aug 9, 2017

@arokem arokem changed the title from [MRG] Enable memory profiling of the examples. to Enable memory profiling of the examples. Aug 9, 2017

@arokem

This comment has been minimized.

Member

arokem commented Aug 9, 2017

OK. I think that this addresses your comments. Could you please take another look?

@coveralls

This comment has been minimized.

coveralls commented Aug 9, 2017

Coverage Status

Coverage increased (+0.001%) to 85.33% when pulling df83022 on arokem:profile-examples into 5595842 on nipy:master.

@coveralls

This comment has been minimized.

coveralls commented Aug 9, 2017

Coverage Status

Coverage increased (+0.001%) to 85.33% when pulling df83022 on arokem:profile-examples into 5595842 on nipy:master.

1 similar comment
@coveralls

This comment has been minimized.

coveralls commented Aug 9, 2017

Coverage Status

Coverage increased (+0.001%) to 85.33% when pulling df83022 on arokem:profile-examples into 5595842 on nipy:master.

@coveralls

This comment has been minimized.

coveralls commented Aug 9, 2017

Coverage Status

Coverage increased (+0.001%) to 85.33% when pulling df83022 on arokem:profile-examples into 5595842 on nipy:master.

@Garyfallidis

This comment has been minimized.

Member

Garyfallidis commented Oct 13, 2017

Rebase please and will merge this shortly :)

@arokem arokem force-pushed the arokem:profile-examples branch from df83022 to 63bbc83 Oct 13, 2017

@arokem

This comment has been minimized.

Member

arokem commented Oct 13, 2017

Done!

@Garyfallidis

This comment has been minimized.

Member

Garyfallidis commented Oct 13, 2017

That was quick dude! 👍

@arokem arokem force-pushed the arokem:profile-examples branch from 63bbc83 to 3d65a11 Oct 13, 2017

@Garyfallidis Garyfallidis merged commit 0072e17 into nipy:master Oct 14, 2017

3 checks passed

codecov/patch 100% of diff hit (target 87.03%)
Details
codecov/project Absolute coverage decreased by -<.01% but relative coverage increased by +12.96% compared to 0964732
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

ShreyasFadnavis pushed a commit to ShreyasFadnavis/dipy that referenced this pull request Sep 20, 2018

Merge pull request nipy#1239 from arokem/profile-examples
Enable memory profiling of the examples.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment