I would like to run a GPU enabled app (Gazebo) inside a docker container on my MacBook Pro.
I seemed to me, through my research, that about a year ago, Docker released a native Docker app for MacOS.
Before that, Docker used to spawn an entire Linux VM and run the container on top of it.
Now, it apparently uses some native hypervisor framework, making it more optimized and closer to the hardware, changing entirely Docker's approach to containerization on a Mac.
All this is not very clear to me and I am not sure of everything I stated.
Is it now possible to use my macbook pro's GPU from a docker container, and, if yes, how ?
The command line I'm using right now, which works for regular X11 apps but not GPU-enabled apps like Gazebo is:
xhost +
docker run -it -e DISPLAY=$ip:0 -v /tmp/.X11-unix:/tmp/.X11-unix image_name bash
In order to do so, you need to install the nvidia-docker2 package and then use the –gpu flag when running your containers. Docker is a powerful tool that … Yes, docker can run on a GPU. In order to do so, you need to install the nvidia-docker2 package and then use the –gpu flag when running your containers.
Docker Desktop currently supports macOS Catalina, macOS Big Sur, and macOS Monterey. At least 4 GB of RAM. VirtualBox prior to version 4.3.30 must not be installed as it is not compatible with Docker Desktop.
Running CUDA container requires Nvidia drivers for Linux and access to Linux devices representing GPU, e.g. /dev/nvidia0. These devices and drivers are not available when Docker is installed on Windows and running inside VirtualBox virtual machine.
Docker can now be installed as a native Windows or native Mac app, launched and utilized from a system toolbar just like any other packaged application.
Docker for Mac uses a virtualization layer called XHyve. It's a lot thinner and more lightweight than VirtualBox or such (emulates fewer peripherals), but it's still virtualization.
Hardware with an IOMMU (and yes, your MacBook Pro has an Intel chipset with such support) can allow a virtualized environment direct access to PCI hardware.
However, you can't cede control of a piece of hardware to a VM and still use that hardware from the host. (Some high-end server network cards work around this by having multiple PCI endpoints, so the host and each guest gets a different endpoint to talk to).
The underlying support in Xhyve isn't there yet (as of this mid-2017 writing), and even on KVM (used by a lot of folks doing pioneering work here), there are only limited reports of success (with a specific video card -- the Radeon HD 5850).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With