help > Errors with docker on Macbook M2
Showing 1-6 of 6 posts
Display:
Results per page:
Aug 5, 2024  05:08 PM | Justin Kirby
Errors with docker on Macbook M2

Hi, I'm trying to get this to run with the docker version on a Macbook Pro M2 using some data from TCIA but am getting the errors shown in the attached document after trying with 2 different DICOM series.  Any idea what's wrong?

Aug 6, 2024  12:08 AM | Christopher Schwarz - Mayo Clinic
RE: Errors with docker on Macbook M2

Justin,
I don't have any experience with your error, but from Googling it, it seems to be a Mac specific issue. Several suggestions are offered  here: https://stackoverflow.com/questions/6666... That addresses this warning "WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested", and I hope that would fix the subsequent errors of "chmod: Invalid file mode: =777" and "Error: mclmcr initialization failed" issue with the Matlab runtime. 


Hopefully this will correct your first example, but I think your second example wouldn't work either way, based on "Warning: Interslice distance varies in this volume (incompatible with NIfTI format).". If your DICOM can't be converted into a .nii file with dcm2niix, then it won't be compatible. If you have some other converter that successfully makes a .nii out of it, you could run that externally and create a new de-faced nifti with mri_reface, then convert that back with ADIR_nii2dicom (but using it with the old DICOM may not work, since it still has the original issues that caused it to fail with dcm2niix).


Hope that helps!
Chris

Aug 6, 2024  01:08 AM | Justin Kirby
RE: Errors with docker on Macbook M2

Thanks Chris.  I tried editing the run_mri_reface_docker.sh to add "--platform linux/amd64" to the docker run command.  This eliminates the warning since I'm specifying a platform, but that didn't resolve the error about mclmcr initialization, which I assume is because that isn't the actual hardware I'm using. 


If I update the script to specify "--platform linux/arm64/v8" I get an error that's essentially indicating an image for mri_reface with that platform doesn't exist on dockerhub. 


After digging into this a little, I read that you should be able to specify that you want to provide a Mac release tailored for Apple silicon using BuildX when you create your Docker image.  E.g. "docker buildx build --platform linux/arm64 -t my-image:latest".  I'd be happy to test this out for you if that's something you can try. 


Also, I was able to fix the "chmod: Invalid file mode: =777" error I was getting by editing your .sh file to remove the space before the = in that line.  I.e. "chmod =777 -R $tmpdir" --> "chmod=777 -R $tmpdir".  I guess Macs are fussier about this syntax than PCs.

Aug 8, 2024  12:08 AM | Christopher Schwarz - Mayo Clinic
RE: Errors with docker on Macbook M2

Justin,
We're going to have to take some time to look into this and get back to you. Your post was news to me that Docker images are not cross-architecture, but producing the mri_reface Docker was really the first forray into containers for me and my team. Our docker build is a little unusual because of the Matlab runtime. We have to use Matlab's own Docker-building functionality to build a working image containing the Matlab runtime, and then use that output as the base for us to add additional layers with our program  and the rest of its dependencies. Installing the off-the-shelf Matlab runtime in our Docker environments produces OpenGL errors in some of the function calls we use, and this only seems to happen inside Docker images (you can find old messages about that on this board). The one installed by Matlab's own docker-builder avoids this; it seems to be a special version somehow. I suspect that these issues will make it a lot tougher to build an image for arm64 that also contains the Matlab runtimes for arm64. One of my colleagues has an M2 laptop and has offered to help test. In short, I want to help you and other arm64/Apple users, but I think it will be a bigger undertaking than the average Docker image. Please be patient, and I will get back to you. In the meantime, my best suggestion is to use our corresponding not-Docker release. You can install the appropriate Matlab runtime, compile niftyreg and ANTs, and hopefully that would work around your issue. For your hardware, the Docker solution may be creating more issues than it is solving.


Best,
Chris

Nov 15, 2024  12:11 AM | James Swift
RE: Errors with docker on Macbook M2

Hi Chris,


I am also struggling to run mri_reface on my m1 mac. I have tried running both the docker and non-docker versions with no success. When testing the docker version, I similarly get an error about mclmcr. I have tried the MATLAB runtimes for 2022a, 2023a, and 2024b (arm64). When using the non-docker version, I get the error, 'cannot execute binary file.' I have already checked that the executable is allowed by my mac permissions. My guess is that the exe distributed in the non-docker version is not compiled for arm64 architecture, but I am admittedly a novice in these things.


Do you have any updates on testing mri_reface with m-type architectures?


Thanks,
James

Nov 15, 2024  01:11 PM | Christopher Schwarz - Mayo Clinic
RE: Errors with docker on Macbook M2

James,
Thank you for letting me know that the not-Docker version isn't compatible with arm64 either. We are gearing up to release a new version in the coming weeks. At that time, I will try to run the compile script on my wife's Macbook, and hopefully it will work to let me provide a mac release. 
Best,
Chris