Nilearn development environment fails with memory error

When setting up the nilearn development environment according to the instructions, the process fails when I run the tests using:

pytest nilearn

Here’s the essence of the error:

E           ValueError: Memory profiler measured an untrustable memory consumption (0.00 MiB). The expected memory limit was 100.00 MiB. Try to bench with larger objects (at least 100MiB in memory).

So far, I haven’t found a way to ‘bench with larger objects’.
Any suggestions?

What prompted the error?

Great question! I didn’t realize I left out all the context :thinking:
Updated the question.

Can you provide more context (envrionment, full logs) ?

This is what I know how to do. Happy to run other commands per your suggestions.

@NicolasGensollen do you have any clue on that one ?

Hi, I had a look but could not reproduce the error. It may be related to the specific operating system and/or special configurations of your machine. Can you provide some information about your operating system?
I am running:

  Operating System: Ubuntu 20.04.4 LTS
            Kernel: Linux 5.13.0-40-generic
      Architecture: x86-64

tested with:


macOS Monterey 12.3.1 (21E258)
Python 3.9.12

(nilearn) Johns-iMac-Pro :: Research/fmri/nilearn » conda -V
conda 4.12.0
(nilearn) Johns-iMac-Pro :: Research/fmri/nilearn » python -m pip -V
pip 22.0.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
Darwin Johns-iMac-Pro.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64
platform darwin -- Python 3.9.12, pytest-7.0.1, pluggy-1.0.0 -- /usr/local/opt/python@3.9/bin/python3.9

In my fork, this is the latest tag that I have:

0.9.1  …
Release `0.9.1` (nilearn#3219)
      * REL 0.9.1

Hi @JohnAtl

Thanks for reporting ! The issue happens in this test:

which is basically creating an object of size 200 MiB and trying to assert that the memory used is less than 100 MiB, in order to verify that this error is correctly raised:

In your case, for some reason, the computed memory used (men_used ) seems to be smaller than 50 MiB, which is triggering this error instead:

I don’t know yet why you get this result and I cannot reproduce the bug on my machine (M1 chip macOS Monterey 12.2.1, python 3.9.12).

One quick and dirty way to get rid of this error is to uninstall memory_profiler, which will skip this test.

Otherwise, I’d be curious to know what value of mem_used you have. You can add a breakpoint() above line 97 above and run pytest -v nilearn/tests/

Hope this helps a little bit, and please let me know how it goes!