OSError Read-only file system when running fMRIprep using Apptainer on HPC

Summary of what happened:

I am using my university’s HPC to run fMRIprep on BIDS formatted data. I encountered this Read-only file error that says the path to our lab’s scratch place cannot be found. I looked through many posts but couldn’t figure out why exactly this happened. It could be due to the templateflow, or lack of space. Could I ask your help to go through my code?

Command used (and if a helper script was used, a link to the helper script or the command generated):

# Prepare computing environment
export LABROOT=/lab_scratch_place
export SCRATCH=/personal_scratch_place
export BIDS_DIR=$LABROOT/BIDS/sub-1
export DERIVS_DIR=$BIDS_DIR/derivatives/fmriprep
export WORK_DIR=$BIDS_DIR/fmriprep_work_dir

export TAG="24.1.0rc2"
export FMRIPREP_IMAGE=$LABROOT/apptainer/.apptainer/fmriprep_${TAG}.sif

export TEMPLATEFLOW_HOST_HOME=$SCRATCH/fMRIPrep-example/apptainer/templateflow
export FMRIPREP_HOST_CACHE=$SCRATCH/.cache/fmriprep

export FS_LICENSE=$LABROOT/apptainer/bin/license.txt
export BIDS_FILTER_FILE=./bids_filter_file.json

mkdir -p $DERIVS_DIR
mkdir -p $WORK_DIR

# Prepare apptainer/singularity command line
APPTAINER_CMD="apptainer run --home $HOME --cleanenv -B $BIDS_DIR:/data -B ${TEMPLATEFLOW_HOST_HOME}:/templateflow -B $WORK_DIR:/work -B $FS_LICENSE:/license -B $BIDS_FILTER_FILE:/filter $FMRIPREP_IMAGE"

# Compose subject ID for each array task
SUBJECT="sub-1"

# Compose the command line with flags for fMRIPrep
cmd="$APPTAINER_CMD /data $DERIVS_DIR participant --participant-label $SUBJECT -w /work --nthreads 16 --mem_mb 256000 --output-spaces MNI152NLin2009cAsym:res-2 func --fs-license-file /license --bids-filter-file /filter --skip_bids_validation --verbose"

Version:

24.1.0rc2

Environment (Docker, Singularity / Apptainer, custom installation):

Apptainer

Data formatted according to a validatable standard? Please provide the output of the validator:

PASTE VALIDATOR OUTPUT HERE

Error log (up to 20 lines):

Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/lib/python3.11/pathlib.py", line 1116, in mkdir
    os.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: '.../sub-1/derivatives/fmriprep/logs'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/lib/python3.11/pathlib.py", line 1116, in mkdir
    os.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: '.../sub-1/derivatives/fmriprep'

Then I have many iterations of “another exception occurred”, until

  File "/opt/conda/envs/fmriprep/lib/python3.11/pathlib.py", line 1116, in mkdir
    os.mkdir(self, mode)
OSError: [Errno 30] Read-only file system: '/root_of_lab_scratch'

I would very much appreciate your help!!! Thanks!


Hi @ClaireZ,

I’d recommend using 24.1.1 since it is a stable release.

The BIDS dir argument should contain the root of the BIDS dir. It should not point to the specific subject folder.

Please remove the work dir from the BIDS dir.

You will still need to export APPTAINERENV_TEMPLATEFLOW_HOME=/templateflow if you want the TEMPLATEFLOW_HOME argument to be set inside the container.the way you want it.

Perhaps define the full path, just to be safe.

That seems like overkill for memory allocation.

May you please return the BIDS validation report?

I don’t see any root_of_lab_scratch argument defined in your script. In either case, can you confirm that you have read/write permissions to all relevant drives?

Best,
Steven

Hi Steven,

Thank you so much for the help! I successfully got fMRIprep running after adopting your suggestions. One persisting question is to store derivates to my lab space. When $DERIVS_DIR points to a path in my lab’s space, the error is still “Read-only file systems”. When I change the derivative directories to my $HOME, the program can run successfully. But I only have 12G in $HOME. This isn’t enough right?

Hi @ClaireZ,

You should see what the permissions are in your lab space, and if you cannot change them so you can write, contact your system admin.

Best,
Steven

1 Like