gz-sim: Crash on M1 chip instantly even using docker
Environment
-
OS Version: macOS Monterey with Apple M1 chip using Docker (Ubuntu 20.04)
-
Source or binary build: Citadel binary build
-
If this is a GUI or sensor rendering bug, describe your GPU and rendering system. Otherwise delete this section.
GUI Bug
- [ ] GUI rendering error. <!-- Search for message like "[GUI] [Msg] Loading plugin [ignition-rendering-ogre2] -->
Full log after launch gazebo such as ign gazebo --verbose
log.txt
Ran ign gazebo -v 3
and it has the same as above. Ran ign gazebo -v 4
and it showed 4 extra blue line. Here log while it was inside middle log like above first log:
log 2.txt
I tried to do it locally and this results the exact same as this issue
So that leaves me two options: Pull gazebo from gazebo website and run docker using feagi.yml
So, I ran feagi.yml following this steps:
- git clone git@github.com:feagi/feagi.git
- cd feagi/docker
- docker-compose -f feagi.yml build --no-cache
- Once it’s complete,
docker-compose -f feagi.yml up
- Open Browser (VNC)
- Wait for it to complete colcon build so it can show you the gazebo. You should see the error instantly once Colon build ends.
The error looks exact same as log.txt (That’s actually where I copied all from)
So, that leaves me the last option.
docker pull gazebo
(This is from gazebo’s docker hub)docker run gazebo
You can see the error instantly too.
The full log (I can’t get more than that)
station1@Station1s-Mini docker % docker run gazebo
Error setting socket option (IP_MULTICAST_IF).
Error setting socket option (IP_MULTICAST_IF).
Did you set the environment variable IGN_IP with a correct IP address?
[172.17.0.2] seems an invalid local IP address.
Using 127.0.0.1 as hostname.
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
qemu: uncaught target signal 6 (Aborted) - core dumped
So this seems like IGN_IP issue, GPU and ogre altogether.
- Generally, mention all circumstances that might affect rendering capabilities: <!-- remove lines that do not apply to keep the list short -->
- [ ] running on real hardware
- [ ] running in Docker/Singularity
- Rendering system info:
Inside docker since it's using Ubuntu 20.04
- On Linux, provide the outputs of the following commands:
```
root@d45c22edad72:~# bash
root@d45c22edad72:~# LANG=C lspci -nn | grep VGA # might require installing pciutils
root@d45c22edad72:~# echo "$DISPLAY"
:1.0
root@d45c22edad72:~# LANG=C glxinfo -B | grep -i '\(direct rendering\|opengl\|profile\)' # might require installing mesa-utils package
direct rendering: Yes
Preferred profile: core (0x1)
Max core profile version: 4.5
Max compat profile version: 3.1
Max GLES1 profile version: 1.1
Max GLES[23] profile version: 3.2
OpenGL vendor string: Mesa/X.org
OpenGL renderer string: llvmpipe (LLVM 11.0.0, 128 bits)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 20.2.6
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL version string: 3.1 Mesa 20.2.6
OpenGL shading language version string: 1.40
OpenGL context flags: (none)
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 20.2.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
root@d45c22edad72:~# ps aux | grep Xorg
root 922 0.0 0.3 151008 7212 pts/0 Sl+ 17:38 0:00 /usr/bin/qemu-x86_64 /usr/bin/grep --color=auto Xorg
root@d45c22edad72:~# sudo env LANG=C X -version
/usr/bin/env: ‘X’: No such file or directory
root@d45c22edad72:~#
```
- On Mac OS, open a terminal and type
system_profiler SPDisplaysDataType
. Copy the output here.
station1@Station1s-Mini docker % system_profiler SPDisplaysDataType
Graphics/Displays:
Apple M1:
Chipset Model: Apple M1
Type: GPU
Bus: Built-In
Total Number of Cores: 8
Vendor: Apple (0x106b)
Metal Family: Supported, Metal GPUFamily Apple 7
Displays:
ASUS VP28U:
Resolution: 5120 x 2880 (5K/UHD+ - Ultra High Definition Plus)
UI Looks like: 2560 x 1440 @ 60.00Hz
Main Display: Yes
Mirror: Off
Online: Yes
Rotation: Supported
Automatically Adjust Brightness: Yes
station1@Station1s-Mini docker %
Description
- Expected behavior: Just able to load gazebo.
ign gazebo
- Actual behavior: log.txt
Addition information: I ran --platform = linux/arm64 too or anything related to this command. Everything else worked except Gazebo.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 42 (15 by maintainers)
It’s officially working, everyone!!!
See here on M1 where I spinned my robot:
https://user-images.githubusercontent.com/65916520/172218164-31af000e-38e4-4da0-9574-aad3cbe7db9f.mov
ON M1! It’s surprisingly faster and almost same speed as my local linux (it lags on docker on linux)
Here is the solution: I found out that Gazebo can run arm64 so I switched from vnc (amd64 by default) to arm64 and I swapped amd64 to arm64 on ros2 for the FOXY ros2/gazebo bridge.
Here is what I used for docker: https://hub.docker.com/r/dorowu/ubuntu-desktop-lxde-vnc/tags (I use dockerfile so it is
FROM dorowu/ubuntu-desktop-lxde-vnc:focal-arm64
)That’s it!!!
Looks like amd64 is NOT supported on Gazebo/M1. Arm64 is available on M1 only.
I believe we can build Gazebo using arm64 only
Thank you, everyone! This helped me a ton! Hope it helps you a lot too, guys! See you around in Gazebo community!
oh looks like that’s also fixed upstream in the backward repo: https://github.com/bombela/backward-cpp/blob/master/backward.hpp#L4220-L4225.
That worked!
I had more issues to be addressed though
src/ign-launch/src/vendor/backward.hpp
I had to replace https://github.com/gazebosim/gz-launch/blob/8c78b6c937943ba1650e887c3a82dbfaea6c154f/src/vendor/backward.hpp#L3937
with
I had to create a symlink of
libzeq.5.dylib
@/usr/local/lib/
for that reason.I was able to reproduce the issue with ign-physics. Could be due to recent changes in Garden.
This patch is probably not a proper fix but it got ign-physics to build on my mac M1 machine:
@srmainwaring @iche033 I got the ogre2 example working with my ignition-rendering7 & m1 mac;
I am unable to complete the colcon build though as the build of ign-physics6 fails.
Have you experienced any issue like this before?
Below is the colcon graph I got from the latest garden yaml file, and the log files are also attached.
FAKE_INSTALL-build-err.log FAKE_INSTALL-build-out.log
As you can read from the file, the error complains
ld: library not found for -lTINYXML2_LIBRARY_/opt/homebrew/Cellar/tinyxml2/9.0.0/lib/libtinyxml2.dylib-NOTFOUND
although I do have libtinyxml2.dylib in /opt/homebrew/Cellar/tinyxml2/9.0.0/lib/.Could this be related to disabling SIP?
@Kakcalu13 can you try exporting the following before running the
simple_demo
:(double check I’ve got that path right). The failure is macOS not resolving an rpath. It’s trying a couple of paths from
CMAKE_PREFIX_PATH
but none of them contain the correct location for the brew installed ogre2.2 libraries.You will need Xcode and the matching Command line tools (which need to be installed from the Apple developer downloads pages).
It looks like you managed to get
ignition-rendering7
built. What was the outcome of building and running the examplessimple_demo
andogre2demo
?I think colcon should show some error msgs on why ign-gui failed.
Some differences I saw between your step 9 and mine are these libraries:
The paths setup in step 10 looks the same as mine. I had one extra export which I’m not sure if it’s actually needed
@Kakcalu13 not quite sure what the status of you build is. In your colcon workspace have you managed to build the main branch of ignition-rendering and dependencies using:
After calling
you should then be able to run
Your cmake log files appear to be reporting missing Xcode framework libraries etc. This can happen if you upgrade Xcode or the command line tools or brew and don’t do a proper clean of all of your build and install directories (i.e. the CMakeCache is stale and subsequent builds get corrupted).
The key step is getting ignition-rendering (
main
branch) built and running the examples. Once you’re at that stage ping me and I can walk you through the rest of the set up.@Kakcalu13 and @brolin-botsync - most of the changes required to support Ignition on macOS using Metal have now been merged into the main branches of various repos. The outstanding PR for macOS is in ignition-gazebo (this PR runs fine on macOS but there are some Linux/OpenGL threading compatibility issues to resolve for GPU enabled sensors).
I believe that the formula for Ogre2.2 in osrf/simulation is also now up to date for Metal and should work on a M1 machine as a couple of the devs reviewing the changes for Metal support were using these machines. Correction: there is an open PR for the M1 patch to the ogre2.2 formulaI should update or remove the wiki notes you refer to above - they have mostly been superseded now.
For Metal support you should use the Garden branch and will need to build from source.
I’d be happy to help you both get a native installation of ignition gazebo running on macOS - it would help figure out what the platform specific installation notes should look like. Starting point is to install Garden and test that the examples in ignition-rendering are working with the ogre2 metal flags (e.g.
ign-rendering/examples/build/ogre2demo ogre2 metal
). If ogre2 metal rendering is running then you should be able to get the full Gazebo environment working.I have not had much luck running ignition using virtualised versions of Ubuntu with accelerated graphics post Ignition Edifice. The main problem is a lack of OpenGL 4.3+ support in the hypervisor drivers. For example VMWare fusion will only support OpenGL 4.1 and that is not sufficient for Ogre2.2. I have not looked at running docker machines with hardware acceleration for a while, but suspect you may run into a similar issue there. Software rendering may work, but that will be an order of magnitude slower for interesting rendering environments.