mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

Determine total memory without psutil

Open cbrnr opened this issue 1 year ago • 16 comments

Fixes #12785. We've always computed gibibytes (GiB), so I've also fixed the unit (was previously GB).

  • [x] Linux
  • [x] macOS
  • [x] Windows

cbrnr avatar Aug 13 '24 18:08 cbrnr

One option to check win/macOS/Linux would be to add to the test something like assert re.match("[0-9]+ GiB", out) is not None in some sys_info test. It would ensure that on all CIs we get some estimate of the memory rather than ? GiB

larsoner avatar Aug 13 '24 18:08 larsoner

This is ready for review.

cbrnr avatar Aug 13 '24 19:08 cbrnr

While I'm at it, I don't get any CPU name on my Mac, and at least for macOS I have an easy fix. Do you want me to include it in this PR or a new one?

cbrnr avatar Aug 13 '24 19:08 cbrnr

Sure, feel free to push here

larsoner avatar Aug 13 '24 19:08 larsoner

This gives

Apple M2 Pro (12 cores)

instead of

arm (12 cores)

I can try to get this to work on Linux and Windows tomorrow.

cbrnr avatar Aug 13 '24 19:08 cbrnr

OK, this is now ready again. I've tested on all three platforms and got nice CPU strings as well as the correct memory size, but if you have hardware such as Intel-based Macs (I only tested on ARM-based Macs), please feel free to check the output of mne.sys_info()!

cbrnr avatar Aug 14 '24 06:08 cbrnr

I'm using wmic on Windows, but I just found out that Microsoft is deprecating this tool. I'll see if I can replace it with some Powershell commands like they suggest.

Candidate replacements:

  • subprocess.check_output(["powershell.exe", "(Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).sum"])
  • subprocess.check_output(["powershell.exe", "(Get-CimInstance Win32_Processor).Name"])

cbrnr avatar Aug 14 '24 10:08 cbrnr

Can we not output GB instead of GiB? no-one except for a few CS and IT / tech-savvy folks will know what GiB is

hoechenberger avatar Aug 14 '24 14:08 hoechenberger

Can we not output GB instead of GiB? no-one except for a few CS and IT / tech-savvy folks will know what GiB is

Only if we really show GB (base 1000).

cbrnr avatar Aug 14 '24 14:08 cbrnr

yes that's what I meant

hoechenberger avatar Aug 14 '24 14:08 hoechenberger

OK, but this changes the numbers then. Previously, we computed GiB but erroneously wrote GB.

cbrnr avatar Aug 14 '24 15:08 cbrnr

IMO, GiB is not that esoteric and people can always look it up with their search engine if they're not familiar. For me the first few hits are unrelated but hits 4 and 5 are "what is a GibiByte (GiB)?" and "GB vs GiB what's the difference?"

drammock avatar Aug 14 '24 15:08 drammock

IMO, GiB is not that esoteric and people can always look it up with their search engine if they're not familiar.

I agree! In principle, I don't care what we use as long as we use the correct unit though.

cbrnr avatar Aug 14 '24 15:08 cbrnr

The tools I checked on Linux use GiB, the activity monitor or macOS says GB. No opinion from me on which to use but agree it would be nice to get the unit right.

Current approach appears to be failing on Windows CIs, though

https://github.com/mne-tools/mne-python/actions/runs/10386163230/job/28756877686?pr=12787#step:17:4174

https://dev.azure.com/mne-tools/mne-python/_build/results?buildId=30965&view=logs&jobId=2bd7b19d-6351-5e7f-8417-63f327ab45bc&j=2bd7b19d-6351-5e7f-8417-63f327ab45bc&t=43b4c425-59e5-5cb3-0374-1f08e81b4191

larsoner avatar Aug 14 '24 15:08 larsoner

I suggest we get this in early for 1.9 rather than just before 1.8. Might be good to have a bit more time to test it, I don't think this is a critical blocker, and we still need to converge a bit.

larsoner avatar Aug 14 '24 16:08 larsoner

I mean, it's only the memory calculation which is currently failing. I could try and play around a bit more, but I'm also fine with moving it to 1.9.

cbrnr avatar Aug 14 '24 16:08 cbrnr

This is now finally ready for review again. Everything seems to be working fine on all platforms.

cbrnr avatar Sep 09 '24 14:09 cbrnr

Thanks @cbrnr !

larsoner avatar Sep 11 '24 15:09 larsoner