Mac M1 installation error

I recently tried to install OTB 8.0.0 on my M1 Macbook and got the following error:

$ ./OTB-8.0.0-Darwin64.run --target /Applications/OTB-8.0.0-Darwin64  
Creating directory /Applications/OTB-8.0.0-Darwin64
Verifying archive integrity...  100%   All good.
Uncompressing OrfeoToolBox 8.0.0  100%  
*****Warning******
OTB python bindings normally require python3.5.
The version of OTB_PYTHON_EXE (/Users/ashnair/miniconda3/bin/python3) is                   3.8.12.
This case is undefined unless you are sure the packages were                   build with this version of python.
OTB python bindings will be configured for /Users/ashnair/miniconda3/bin/python3                     ( version: 3.8.12 )
Found python library: /opt/local/lib/libpython3.8.dylib
Configuring...
Installing uninstall script for OTB 'tools/uninstall_otb.sh'

source './otbenv.profile' file to set required environment variables
eg: '. /Applications/OTB-8.0.0-Darwin64/otbenv.profile'
You can also copy above line to  ~/.profile to keep changes permanently!
More documentation can be found in /Applications/OTB-8.0.0-Darwin64/README

$ python -c "import otbApplication"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Applications/OTB-8.0.0-Darwin64/lib/python/otbApplication.py", line 15, in <module>
    import _otbApplication
ImportError: dlopen(/Applications/OTB-8.0.0-Darwin64/lib/python/_otbApplication.so, 0x0002): tried: '/Applications/OTB-8.0.0-Darwin64/lib/python/_otbApplication.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_otbApplication.so' (no such file), '/usr/lib/_otbApplication.so' (no such file)

I’m guessing this might be because otb wasn’t compiled to work with M1. Is there a solution for this?

Hi,

We currently compile OTB only on intel Macs (that’s why there is the Darwin64 suffix), you are right we never have tried to compile it on M1 as there are a lot of dependencies and some of them are not ported to M1 yet. I think that Rosetta which translates x86_64 instructions to ARM64 can do the job with OTB but I don’t think that python also has this Rosetta interface. The solution will be available in a couple of days : an official docker image.

We will announce it on the forum and on the website. As we don’t have an M1 mac, tests will be greatly appreciated

Best regards

Dear @ashnair1,

Two docker images a available now. You can read more about this here.

Sincerely.
Julien :slight_smile:

1 Like

Thanks a lot Julien.

Funnily enough I ended up building docker images as well. The following repo contains images for all versions from 7.0.0 to 8.0.0 and uses github actions to build them.

1 Like

I too have issues with the M1 Max and installation. I’ve installed using the docker image as shown on the Mac installation. It appears to install yet when I run the command for CLI and the GUI, I get the following errors:

CLI
docker run -it orfeotoolbox/otb
WARNING: The requested image’s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
root@623e06d86243:/#

GUI
docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix/ --device=/dev/dri:/dev/dri orfeotoolbox/otb monteverdi
WARNING: The requested image’s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
docker: Error response from daemon: error gathering device information while adding custom device “/dev/dri”: no such file or directory.
ERRO[0000] error waiting for container: context canceled

Can I get guidance on how to proceed?

Thank you.

Hi @jridout

Can you try calling the otb docker image with : docker run -it orfeotoolbox/otb --platform linux/amd64
This command line option tells docker to use the intel emulation layer embedded in MacOS called Rosetta
If you want to use GUI apps on M1 you need to install X11 / XQuartz which is not installed by default on MacOS.
https://www.xquartz.org/

Let me know if it works
Regards

Thanks for your reply and I appreciate the help.
I have installed X11 and Rosetta and still get the same errors. Using the above syntax docker run -it orfeotoolbox/otb --platform linux/amd64 I receive the following error:

WARNING: The requested image’s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: “–platform”: executable file not found in $PATH: unknown.
ERRO [0000] error waiting for container: context canceled

Thanks again for the help!

My bad, you have to put the platform argument before orfeotoolbox/otb because it is an argument to Docker, not an argument to the otb image.
docker run -it --platform linux/amd64 orfeotoolbox/otb

Success! Thank you for your help, it is much appreciated.

I’m still having issues trying to start the Monteverdi GUI. I’m now receiving the error:

Error response from daemon: error gathering device information while adding custom device “/dev/dri”: no such file or directory.
ERRO[0000] error waiting for container: context canceled

I can process using the CLI but it would be nice to work in the GUI as well.

Perfect, that is a good news for the CLI!

About the GUI, it is because /dev/dri is not available on MacOS, you can try

docker run -it --env="DISPLAY=host.docker.internal:0" -v /tmp/.X11-unix:/tmp/.X11-unix:rw <image name>

If if it is not working the first time, from the XQuartz preferences, in the security tab, make sure Allow connections from network clients is enabled.

Then in a terminal launch :
xhost +localhost

Then relaunch the docker command

Let me know

Hi i think i followed the install instructions exactly as on the docker hub page. i also installed xquartz and allowed all connections before running:
xhost + localhost
and
docker run -it --env="DISPLAY=host.docker.internal:0" -v /tmp/.X11-unix/:/tmp/.X11-unix/:rw orfeotoolbox/otb:8.1.0 monteverdi

however i get this message:

WARNING: The requested image’s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
qt.qpa.xcb: could not connect to display host.docker.internal:0
qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “” even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: linuxfb, minimal, offscreen, vnc, xcb.

qemu: uncaught target signal 6 (Aborted) - core dumped

a container was build with a warning though:

I am not sure if everything worked out as expected since I got those warnings.
Please let me know if you have any feedback to those warnings :slight_smile:

best regards

Hi hvutuyen,

The warning is normal since your CPU architecture is ARM64 (M1) and the docker image is built upon amd64 architecture. In MacOS there is a thing called Rosetta that can launch amd64 apps (including docker images) on arm64.

I think there is something missing in the docker hub page, can you try :
docker run -it --env="DISPLAY=host.docker.internal:0" -v /tmp/.X11-unix/:/tmp/.X11-unix/:rw --platform=linux/amd64 orfeotoolbox/otb:8.1.0 monteverdi

The warning will disappear, but there is something wrong with the display variable, I will get back to you with more informations (We don’t have an M1 mac to test so every feedback is welcomed)
If this still does not work with the platform argument, can you try replacing
host.docker.internal:0
by
${HOSTNAME}:0

Best regards

Hi thibaut.romain,
thanks for the fast response!

i tried
docker run -it --env="DISPLAY=host.docker.internal:0" -v /tmp/.X11-unix/:/tmp/.X11-unix/:rw --platform=linux/amd64 orfeotoolbox/otb:8.1.0 monteverdi

and

docker run -it --env="DISPLAY=${HOSTNAME}:0" -v /tmp/.X11-unix/:/tmp/.X11-unix/:rw --platform=linux/amd64 orfeotoolbox/otb:8.1.0 monteverdi

but i still get the same warning:

qt.qpa.xcb: could not connect to display host.docker.internal:0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Best regards

Available platform plugins are: linuxfb, minimal, offscreen, vnc, xcb.

qemu: uncaught target signal 6 (Aborted) - core dumped

also the warning on the container is still there.

I try to install the toolbox and use it as a plugin with QGIS. I have not found any instructions how to install/use it properly for M1 yet.
Do I need the xquartz for that purpose?

The only way to use OTB in M1 macs is to use the docker image, because the toolbox is built for amd64 architecture and building it for arm64 means a lot of work for all the dependencies of OTB to get it working, i don’t know if it is going to happen.

You are trying to use the gui part of OTB, is it mandatory for you? the GUI use X11, which is inside the app XQuartz that is mandatory to launch before using X11 gui apps. If it isn’t mandatory i would recommend using only the cli, in that case you don’t need xquartz and all DISPLAY environment etc. I know that the cli works well on M1 Macs. The main problem is interfacing xquartz and docker. I will make some further research and get back to you asap.

The “host.docker.internal:0” error guides me to a docker configuration problem
I also see a qemu error, are you using docker inside a VM ? that would explain the error above

I haven’t tried yet to use OTB with QGIS on M1 Macs, i don’t know if QGIS will recognize the otb applications as they are not built for arm64

Best regards

I just found out, I don’t necessarily need xquartz :slight_smile:
And I don’t think it is possible to import the Orfeo Toolbox into QGIS out of a Docker Image, since there is no physical path/installation to the Orfeo application, as far as I understood.

thanks for your help, I really appreciate it!

best regards

Glad to here you succeed with the cli, I think too that it is impossible to import OTB from a docker image

If you see any other problem with the M1 please let us know, the more testers there are, the quicker we can try to fix problems on this fairly new platform.

Best Regards