cpp-lln-lab / bidsMReye

BIDS app using deepMReye to decode eye motion for fMRI time series data.
https://bidsmreye.readthedocs.io/en/latest/
Other
5 stars 5 forks source link

Issue with cache permissions #183

Closed dal50musc closed 3 months ago

dal50musc commented 11 months ago

Is there an existing issue for this?

Expected Behavior

I am trying to run an example of bidsmreye

Current Behavior

I received this permission error when using the generalize action on bidsMReye. Error says it cannot write data to cache folder.

Error message

(base) Daniels-iMac:delete daniellench$ sudo docker run --rm -it \
--user "$(id -u):$(id -g)" \
-v $PWD/tests/data/moae_fmriprep:/home/neuro/data \
-v $PWD/outputs/moae_fmriprep/derivatives:/home/neuro/outputs/ \
cpplab/bidsmreye:latest \
/home/neuro/data/             /home/neuro/outputs/             participant \
--action generalize
Password:
whoami: cannot find name for user ID 501
2023-12-14 16:59:58.877876: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-12-14 16:59:59.109886: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2023-12-14 16:59:59.109944: I tensorflow/compiler/xla/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2023-12-14 16:59:59.903277: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory
2023-12-14 16:59:59.903473: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2023-12-14 16:59:59.903533: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
[17:00:02] WARNING  bidsMReye - [17:00:02] - Matplotlib created a temporary config/cache directory at /tmp/matplotlib-u0nw0afc because the default    __init__.py:500
                    path (/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to                 
                    a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.                                  
WARNING
[17:00:03] WARNING  bidsMReye - [17:00:03] - log level: WARNING                                                                                      bidsmreye.py:112
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /opt/miniconda-latest/envs/bidsmreye/lib/python3.9/site-packages/pooch/utils.py:252 in           │
│ make_local_storage                                                                               │
│                                                                                                  │
│   249 │   │   │   os.makedirs(path, exist_ok=True)                                               │
│   250 │   │   else:                                                                              │
│   251 │   │   │   action = "write to"                                                            │
│ ❱ 252 │   │   │   with tempfile.NamedTemporaryFile(dir=path):                                    │
│   253 │   │   │   │   pass                                                                       │
│   254 │   except PermissionError as error:                                                       │
│   255 │   │   message = [                                                                        │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │  action = 'write to'                                                                         │ │
│ │     env = None                                                                               │ │
│ │ message = [                                                                                  │ │
│ │           │   "[Errno 13] Permission denied: '/home/neuro/bidsMReye/models/tmpe3lsq2cm'",    │ │
│ │           │   "| Pooch could not write to data cache folder                                  │ │
│ │           '/home/neuro/bidsMReye/models'.",                                                  │ │
│ │           │   'Will not be able to download data files.'                                     │ │
│ │           ]                                                                                  │ │
│ │    path = '/home/neuro/bidsMReye/models'                                                     │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /opt/miniconda-latest/envs/bidsmreye/lib/python3.9/tempfile.py:545 in NamedTemporaryFile         │
│                                                                                                  │
│   542 │   if _os.name == 'nt' and delete:                                                        │
│   543 │   │   flags |= _os.O_TEMPORARY                                                           │
│   544 │                                                                                          │
│ ❱ 545 │   (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)                   │
│   546 │   try:                                                                                   │
│   547 │   │   file = _io.open(fd, mode, buffering=buffering,                                     │
│   548 │   │   │   │   │   │   newline=newline, encoding=encoding, errors=errors)                 │
│                                                                                                  │
│ ╭─────────────────── locals ───────────────────╮                                                 │
│ │   buffering = -1                             │                                                 │
│ │      delete = True                           │                                                 │
│ │         dir = '/home/neuro/bidsMReye/models' │                                                 │
│ │    encoding = None                           │                                                 │
│ │      errors = None                           │                                                 │
│ │       flags = 131266                         │                                                 │
│ │        mode = 'w+b'                          │                                                 │
│ │     newline = None                           │                                                 │
│ │ output_type = <class 'str'>                  │                                                 │
│ │      prefix = 'tmp'                          │                                                 │
│ │      suffix = ''                             │                                                 │
│ ╰──────────────────────────────────────────────╯                                                 │
│                                                                                                  │
│ /opt/miniconda-latest/envs/bidsmreye/lib/python3.9/tempfile.py:255 in _mkstemp_inner             │
│                                                                                                  │
│   252 │   │   file = _os.path.join(dir, pre + name + suf)                                        │
│   253 │   │   _sys.audit("tempfile.mkstemp", file)                                               │
│   254 │   │   try:                                                                               │
│ ❱ 255 │   │   │   fd = _os.open(file, flags, 0o600)                                              │
│   256 │   │   except FileExistsError:                                                            │
│   257 │   │   │   continue    # try again                                                        │
│   258 │   │   except PermissionError:                                                            │
│                                                                                                  │
│ ╭─────────────────────────────── locals ────────────────────────────────╮                        │
│ │         dir = '/home/neuro/bidsMReye/models'                          │                        │
│ │        file = '/home/neuro/bidsMReye/models/tmpe3lsq2cm'              │                        │
│ │       flags = 131266                                                  │                        │
│ │        name = 'e3lsq2cm'                                              │                        │
│ │       names = <tempfile._RandomNameSequence object at 0x7f46e8840e80> │                        │
│ │ output_type = <class 'str'>                                           │                        │
│ │         pre = 'tmp'                                                   │                        │
│ │         seq = 0                                                       │                        │
│ │         suf = ''                                                      │                        │
│ ╰───────────────────────────────────────────────────────────────────────╯                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
PermissionError: [Errno 13] Permission denied: '/home/neuro/bidsMReye/models/tmpe3lsq2cm'

The above exception was the direct cause of the following exception:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /opt/miniconda-latest/envs/bidsmreye/bin/bidsmreye:8 in <module>                                 │
│                                                                                                  │
│   5 from bidsmreye.bidsmreye import cli                                                          │
│   6 if __name__ == '__main__':                                                                   │
│   7 │   sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])                         │
│ ❱ 8 │   sys.exit(cli())                                                                          │
│   9                                                                                              │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ __annotations__ = {}                                                                         │ │
│ │    __builtins__ = <module 'builtins' (built-in)>                                             │ │
│ │      __cached__ = None                                                                       │ │
│ │         __doc__ = None                                                                       │ │
│ │        __file__ = '/opt/miniconda-latest/envs/bidsmreye/bin/bidsmreye'                       │ │
│ │      __loader__ = <_frozen_importlib_external.SourceFileLoader object at 0x7f472cb60c40>     │ │
│ │        __name__ = '__main__'                                                                 │ │
│ │     __package__ = None                                                                       │ │
│ │        __spec__ = None                                                                       │ │
│ │             cli = <function cli at 0x7f4719f9ab80>                                           │ │
│ │              re = <module 're' from                                                          │ │
│ │                   '/opt/miniconda-latest/envs/bidsmreye/lib/python3.9/re.py'>                │ │
│ │             sys = <module 'sys' (built-in)>                                                  │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /opt/miniconda-latest/envs/bidsmreye/lib/python3.9/site-packages/bidsmreye/bidsmreye.py:54 in    │
│ cli                                                                                              │
│                                                                                                  │
│    51 │   │   log_level = min(len(log_levels()) - 1, max(log_level + adjustment, 0))             │
│    52 │   log_level_name = log_levels()[log_level]                                               │
│    53 │                                                                                          │
│ ❱  54 │   bidsmreye(                                                                             │
│    55 │   │   bids_dir=args.bids_dir,                                                            │
│    56 │   │   output_dir=args.output_dir,                                                        │
│    57 │   │   analysis_level=args.analysis_level,                                                │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │           args = Namespace(bids_dir='/home/neuro/data/', output_dir='/home/neuro/outputs/',  │ │
│ │                  analysis_level='participant', action='generalize', participant_label=None,  │ │
│ │                  task=None, run=None, space=None, log_level=None, debug=False,               │ │
│ │                  reset_database=False, bids_filter_file=None, non_linear_coreg=False,        │ │
│ │                  model='1to6')                                                               │ │
│ │           argv = [                                                                           │ │
│ │                  │   '/opt/miniconda-latest/envs/bidsmreye/bin/bidsmreye',                   │ │
│ │                  │   '/home/neuro/data/',                                                    │ │
│ │                  │   '/home/neuro/outputs/',                                                 │ │
│ │                  │   'participant',                                                          │ │
│ │                  │   '--action',                                                             │ │
│ │                  │   'generalize'                                                            │ │
│ │                  ]                                                                           │ │
│ │      log_level = 2                                                                           │ │
│ │ log_level_name = 'WARNING'                                                                   │ │
│ │         parser = MuhParser(prog='bidsmreye', usage=None, description='BIDS app using         │ │
│ │                  deepMReye to decode eye motion for fMRI time series data.',                 │ │
│ │                  formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', │ │
│ │                  add_help=True)                                                              │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /opt/miniconda-latest/envs/bidsmreye/lib/python3.9/site-packages/bidsmreye/bidsmreye.py:124 in   │
│ bidsmreye                                                                                        │
│                                                                                                  │
│   121 │   log.debug(f"Configuration:\n{cfg}")                                                    │
│   122 │                                                                                          │
│   123 │   if action in {"all", "generalize"} and isinstance(cfg.model_weights_file, str):        │
│ ❱ 124 │   │   cfg.model_weights_file = download(cfg.model_weights_file)                          │
│   125 │                                                                                          │
│   126 │   dispatch(analysis_level=analysis_level, action=action, cfg=cfg)                        │
│   127                                                                                            │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │             action = 'generalize'                                                            │ │
│ │     analysis_level = 'participant'                                                           │ │
│ │           bids_dir = '/home/neuro/data/'                                                     │ │
│ │        bids_filter = None                                                                    │ │
│ │   bids_filter_file = None                                                                    │ │
│ │                cfg = Config(                                                                 │ │
│ │                      │   input_dir=PosixPath('/home/neuro/data'),                            │ │
│ │                      │   output_dir=PosixPath('/home/neuro/outputs/bidsmreye'),              │ │
│ │                      │   subjects=['01'],                                                    │ │
│ │                      │   space=['MNI152NLin6Asym', 'T1w'],                                   │ │
│ │                      │   task=['auditory'],                                                  │ │
│ │                      │   run=[],                                                             │ │
│ │                      │   model_weights_file='1to6',                                          │ │
│ │                      │   bids_filter={                                                       │ │
│ │                      │   │   'bold': {                                                       │ │
│ │                      │   │   │   'datatype': 'func',                                         │ │
│ │                      │   │   │   'suffix': '^bold$',                                         │ │
│ │                      │   │   │   'extension': 'nii.*'                                        │ │
│ │                      │   │   },                                                              │ │
│ │                      │   │   'mask': {'suffix': 'mask', 'extension': 'p'},                   │ │
│ │                      │   │   'no_label': {                                                   │ │
│ │                      │   │   │   'desc': 'nolabel',                                          │ │
│ │                      │   │   │   'suffix': '^bidsmreye$$',                                   │ │
│ │                      │   │   │   'extension': 'npz'                                          │ │
│ │                      │   │   },                                                              │ │
│ │                      │   │   'eyetrack': {'suffix': '^eyetrack$$', 'extension': 'tsv'},      │ │
│ │                      │   │   'eyetrack_qc': {                                                │ │
│ │                      │   │   │   'suffix': '^eyetrack$$',                                    │ │
│ │                      │   │   │   'extension': 'json'                                         │ │
│ │                      │   │   }                                                               │ │
│ │                      │   },                                                                  │ │
│ │                      │   debug=False,                                                        │ │
│ │                      │   reset_database=False,                                               │ │
│ │                      │   non_linear_coreg=False                                              │ │
│ │                      )                                                                       │ │
│ │              debug = False                                                                   │ │
│ │     log_level_name = 'WARNING'                                                               │ │
│ │ model_weights_file = '1to6'                                                                  │ │
│ │   non_linear_coreg = False                                                                   │ │
│ │         output_dir = '/home/neuro/outputs/'                                                  │ │
│ │  participant_label = None                                                                    │ │
│ │     reset_database = False                                                                   │ │
│ │                run = None                                                                    │ │
│ │              space = None                                                                    │ │
│ │               task = None                                                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /opt/miniconda-latest/envs/bidsmreye/lib/python3.9/site-packages/bidsmreye/download.py:111 in    │
│ download                                                                                         │
│                                                                                                  │
│   108 │   │                                                                                      │
│   109 │   │   file_idx = available_models().index(model_name)                                    │
│   110 │   │   filename = f"dataset_{available_models()[file_idx]}.h5"                            │
│ ❱ 111 │   │   output_file = POOCH.fetch(filename, progressbar=True)                              │
│   112 │   │   if isinstance(output_file, str):                                                   │
│   113 │   │   │   output_file = Path(output_file)                                                │
│   114                                                                                            │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │      file_idx = 7                                                                            │ │
│ │      filename = 'dataset_1to6.h5'                                                            │ │
│ │    model_name = '1to6'                                                                       │ │
│ │    output_dir = PosixPath('/home/neuro/bidsMReye/models')                                    │ │
│ │   output_file = PosixPath('/home/neuro/bidsMReye/models/dataset_1to6')                       │ │
│ │         POOCH = <pooch.core.Pooch object at 0x7f4719fa2340>                                  │ │
│ │ registry_file = <_io.BufferedReader                                                          │ │
│ │                 name='/opt/miniconda-latest/envs/bidsmreye/lib/python3.9/site-packages/bids… │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /opt/miniconda-latest/envs/bidsmreye/lib/python3.9/site-packages/pooch/core.py:563 in fetch      │
│                                                                                                  │
│   560 │   │   self._assert_file_in_registry(fname)                                               │
│   561 │   │                                                                                      │
│   562 │   │   # Create the local data directory if it doesn't already exist                      │
│ ❱ 563 │   │   make_local_storage(str(self.abspath))                                              │
│   564 │   │                                                                                      │
│   565 │   │   url = self.get_url(fname)                                                          │
│   566 │   │   full_path = self.abspath / fname                                                   │
│                                                                                                  │
│ ╭───────────────────────── locals ──────────────────────────╮                                    │
│ │  downloader = None                                        │                                    │
│ │       fname = 'dataset_1to6.h5'                           │                                    │
│ │   processor = None                                        │                                    │
│ │ progressbar = True                                        │                                    │
│ │        self = <pooch.core.Pooch object at 0x7f4719fa2340> │                                    │
│ ╰───────────────────────────────────────────────────────────╯                                    │
│                                                                                                  │
│ /opt/miniconda-latest/envs/bidsmreye/lib/python3.9/site-packages/pooch/utils.py:264 in           │
│ make_local_storage                                                                               │
│                                                                                                  │
│   261 │   │   │   message.append(                                                                │
│   262 │   │   │   │   f"Use environment variable '{env}' to specify a different location."       │
│   263 │   │   │   )                                                                              │
│ ❱ 264 │   │   raise PermissionError(" ".join(message)) from error                                │
│   265                                                                                            │
│   266                                                                                            │
│   267 @contextmanager                                                                            │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │  action = 'write to'                                                                         │ │
│ │     env = None                                                                               │ │
│ │ message = [                                                                                  │ │
│ │           │   "[Errno 13] Permission denied: '/home/neuro/bidsMReye/models/tmpe3lsq2cm'",    │ │
│ │           │   "| Pooch could not write to data cache folder                                  │ │
│ │           '/home/neuro/bidsMReye/models'.",                                                  │ │
│ │           │   'Will not be able to download data files.'                                     │ │
│ │           ]                                                                                  │ │
│ │    path = '/home/neuro/bidsMReye/models'                                                     │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
PermissionError: [Errno 13] Permission denied: '/home/neuro/bidsMReye/models/tmpe3lsq2cm' | Pooch could not write to data cache folder 
'/home/neuro/bidsMReye/models'. Will not be able to download data files.

Environment

- OS: Ventura
- Matlab:2023a
- SPM:12

Branch

- branch:
- version: latest

Anything else?

No response

github-actions[bot] commented 11 months ago

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

Remi-Gau commented 3 months ago

will fix by downloading the model in the output folder rather than in the docker image to avoid write access issues