External Email - Use Caution
Based on your description and the log file showing recon-all getting stuck at the mri_add_xform_to_header step after upgrading to FreeSurfer 7.4.1 Ubuntu 22, along with the need to use a higher-resource GCP machine, here are some insights and suggestions:
🚀 1. Memory Requirements and Ubuntu 22
· While the official release notes for FreeSurfer 7.4.1 do not explicitly state increased memory requirements for Ubuntu 22, the underlying system libraries (e.g., glibc) and dependencies in Ubuntu 22 might be more memory-intensive. This could explain why the same workflow now requires more memory . · The Ubuntu 22 version might have subtle differences in how it handles memory allocation or caching compared to Ubuntu 20, leading to higher baseline memory usage.
⚙️ 2. Threading and Resource Limits
· You've already reduced -openmp threads from 4 to 2, which is a good step. However, further reduction might not help significantly if the issue is related to memory rather than CPU. · Consider explicitly setting thread limits for other components: · ITK threads: Ensure ITK-based tools (e.g., mri_nu_correct.mni) are also limited. Use environment variables like ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=2 or ANTS_RANDOM_SEED=1 (for ANTs tools) to reduce parallelism. · Python/NumPy threads: If any Python scripts are involved, set OMP_NUM_THREADS=1 or MKL_NUM_THREADS=1 to prevent multi-threading.
🗃️ 3. Disk I/O and Swap Usage
· The log shows the process uses swap space (32GB). Excessive swapping can cause bottlenecks, especially if disk I/O is slow. · Monitor disk I/O during the stuck phase using tools like iostat. If I/O wait is high, consider using a machine with faster disk storage (e.g., SSD). · Reduce swap usage by lowering swappiness (sysctl vm.swappiness=10) or disabling swap entirely if possible, as swapping can severely slow down processing .
🔍 4. Debugging the Stuck Process
· When mri_add_xform_to_header gets stuck, check: · Memory usage: Use top or htop to see if memory is maxed out. · Process state: Use strace -p <PID> to see if the process is blocked on a system call (e.g., I/O or memory allocation). · Logs: Look for clues in recon-all.log or syslog for OOM (Out-of-Memory) killer activity.
🛠️ 5. FreeSurfer-Specific Optimizations
· Skip unnecessary steps: If you are re-running recon-all, use flags like -no-isrunning to skip checks, or -noaseg if you don't need subcortical segmentation. · Use expert options: Create a xopts file with memory-saving flags, e.g.,: ``` -nu-intensity-correct-flags " --n 1 --proto-iters 1000 " -talairach-flags " -T 0.005 " ``` · Reduce image resolution: Although not ideal, using -cm (conform to median) or -qcache might help, but this affects output quality.
📊 6. Alternative: Container-Level Memory Limits
· If running in Docker, explicitly set memory limits to avoid overcommit: ```bash docker run --memory 24g --memory-swap 24g ... ``` This prevents the container from using swap, which might force more efficient memory usage .
🔄 7. Fallback: Use Ubuntu 20 Version
· If optimizations fail, consider sticking with the Ubuntu 20 version of FreeSurfer 7.4.1, as it worked reliably for you. The Ubuntu 22 upgrade might not be necessary unless you need specific fixes or compatibility.
💎 Conclusion
The memory increase in Ubuntu 22 might be due to underlying system changes rather than FreeSurfer itself. Try reducing threads further, monitoring disk I/O, and adjusting memory limits. If the issue persists, use the Ubuntu 20 version or upgrade to a more recent FreeSurfer version (e.g., 8.0+) which may have better memory management .
For more details, refer to the FreeSurfer Release Notes and DownloadAndInstall pages.
M.J.H. Dirven
On Fri, Sep 5, 2025, 20:18 Suzanne Witt suzannewitt@flywheel.io wrote:
External Email - Use CautionHello,
I have previously been running Freesurfer 7.4.1 Ubuntu 20 from a Docker container on a GCP n1-highmem-4 machine (4 CPUs, 26GB RAM, 207GB Disk, 32GB Swap) with no issues. I recently updated the Docker image to install Freesurfer 7.4.1 Ubuntu 22 from the official distribution, and now “recon-all” is getting stuck after mri_nu_correct.mni completes and at the very start of “mri_add_xform_to_header -c /usr/local/freesurfer/subjects/05/mri/transforms/talairach.xfm nu.mgz nu.mgz”.
Currently, in order to get Freesurfer 7.4.1 Ubuntu 22 to run to completion, I am having to launch the jobs on a GCP n1-highmem-8 machine (8 CPUs, 52GB RAM, 207GB Disk, 32GB Swap).
I am not seeing anything in either the release notes or the message boards to suggest that the Ubuntu 22 version of Freesurfer 7.4.1 has additional memory requirements compared with the Ubuntu 20 version. I have tested reducing both of the omp threads and itk threads from 4 to 2. I am also not running with the “parallel” flag. Are there any other options that can be used to reduce the memory usage of the Ubuntu 22 version of Freesurfer 7.4.1?
I’ve attached a typical log file showing the recon-all workflow getting stuck at the “mri_add_xform_to_header” step.
cheers.
Suzanne T. Witt, PhD
Scientific Solutions Engineer
suzannewitt@flywheel.io
she/her
[image: A close-up of a logo Description automatically generated]
Sign up to receive our monthly updates https://secure-web.cisco.com/1yipTZHLgLQzEDOTwlegpN9Mp4brS1wWsbahzxQ9yRI6Gui9Avgn8jXKzKSUji2wBBvoOkGJC8lMOrTZxYrEQiAlXiEvUBkA1sDb6cGVdYrSRFhLZhlN5JpzDlPiGkomTnfGpEOHf9UFl2p4YGVS7Z5Tji5-eAwFVRHvyNR4Z_wBe351NB6ECKhs68oqt5d2ZZgb56hCyFKpkWJT2M08ihna3nLVvP0p1O_vX8UKFQEMNhRqlSBL0Oq6zrP-xcTevdzdMjIjyvmYwZF8DXn0Tl7vgIZ-98iijyykc0hOxDZPuozIw62HQLJS-OFvXFEZZ/https%3A%2F%2Fflywheel.io%2Fsubscribe-to-newsletter%2F%3Futm_source%3Demail%26utm_medium%3Dsignature%26utm_campaign%3Demployeesignature _______________________________________________ Freesurfer mailing list -- freesurfer@nmr.mgh.harvard.edu To unsubscribe send an email to freesurfer-leave@nmr.mgh.harvard.edu
https://secure-web.cisco.com/1um6AAentUpccoiFkXYE2zuFHPQ65XgpgNPUH0ut5-kreBr... The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Mass General Brigham Compliance HelpLine at https://secure-web.cisco.com/1bZHOXijxgCTMUJKrgh6pSRvPUDBR2876ii2yd4M5omV7pO... < https://secure-web.cisco.com/1bZHOXijxgCTMUJKrgh6pSRvPUDBR2876ii2yd4M5omV7pO... .