macos icon indicating copy to clipboard operation
macos copied to clipboard

Troubles with AMD and WSL2

Open lars18th opened this issue 1 year ago • 12 comments

Operating system

Windows 11 Docker Desktop WSL2 with AMD Ryzen CPU

Description

When using with one AMD Ryzen cpu the virtual machine is very slow with more than one CPU_CORE. The only solution is the use CPU_CORES="1". When using ["2"..."6"] values the target system will be very slow and it consumes a lot of CPU (checked with the top command inside the container).

I don't know if the problem are specific missing CPU_FLAGS or another problem. The memory size doesn't have any impact in the performance (if you have suficient WSL2 memory free).

Docker compose

docker run -it --rm --name macos -p 8006:8006 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN -v "${PWD:-.}/macos:/storage" -v "${PWD:-.}/shared:/shared" --stop-timeout 120  -e RAM_SIZE="18G" -e CPU_CORES="1" dockurr/macos

Docker log

❯ Starting macOS for Docker v2.14...
❯ For support visit https://github.com/dockur/macos
❯ CPU: AMD Ryzen 5 5600G | RAM: 30/32 GB | DISK: 335 GB (v9fs) | KERNEL: 6.6.87.2-microsoft-standard-WSL2...

❯ Building boot image...
❯
❯ Model: iMacPro1,1
❯ Rom: 0016cb16f2c9
❯ Serial: C02WTJZ1HX87
❯ Board: C02823701GUJG361H
❯
❯ Booting macOS using QEMU v10.0.0...
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
BdsDxe: failed to load Boot0080 "Mac OS X" from PciRoot(0x0)/Pci(0xA,0x0)/VenMedia(BE74FCF7-0B7C-49F3-9147-01F4042E6842,CBCFDE5C1B41E14D800485EC59C37C30)/\914E1168-9D84-4B96-8EB1-B5054FFE4946\System\Library\CoreServices\boot.efi: Not Found
BdsDxe: failed to load Boot0001 "UEFI Misc Device" from PciRoot(0x0)/Pci(0xA,0x0): Not Found
BdsDxe: loading Boot0002 "UEFI Misc Device 2" from PciRoot(0x0)/Pci(0x5,0x0)
BdsDxe: starting Boot0002 "UEFI Misc Device 2" from PciRoot(0x0)/Pci(0x5,0x0)
#[EB|LOG:EXITBS:END] _
#[EB.BST.FBS|-]
#[EB|B:BOOT]
#[EB|LOG:HANDOFF TO XNU] _
======== End of efiboot serial output. ========
usb_desc_get_descriptor: 2 unknown type 33 (len 10)
usb_desc_get_descriptor: 1 unknown type 33 (len 10)

Screenshots (optional)

No response

lars18th avatar Jul 02 '25 13:07 lars18th

Hi,

I had trouble running it on an AMD based Synology NAS. It was even crashing the whole NAS (first time I experienced that a container would crash the host).

However, by adding the CPU_MODEL parameter I was able to run it stable with multiple CPU cores.

Maybe it helps.

environment: CPU_CORES: "2" CPU_MODEL: "Broadwell-noTSX"

JMan7777 avatar Sep 07 '25 03:09 JMan7777

Hi @JMan7777 ,

I feel it doesn't fixes the trouble. With -e CPU_MODEL="Broadwell-noTSX" -e CPU_CORES="2" dockurr/macos it doesn't boot.

Perhaps we need to explore more specific CPU_FLAGS for Ryzen CPUs.

lars18th avatar Sep 12 '25 08:09 lars18th

mine always get's stuck after it downloaded the image from apple after i selected the disk where to intsall it. i`m on a ryzen 7 pro 7840hs. nothing wored yet, but i'll keep trying.

pmenzel2022 avatar Sep 16 '25 12:09 pmenzel2022

Somethig requires to be fixed to run it with AMD Ryzen processors without troubles. At time I recommend to use -e CPU_CORES="1" as a workaround. It's a bit slow, but it works. This approach is already implemented in #297

lars18th avatar Sep 17 '25 07:09 lars18th

hmmm... i can't confirm this.

even with only one CPU_CORES it get stuck after the image or whatever from apple was downloaded and it should start installing with the apple logo. on an old intel i7 it's not a problem at all.

pmenzel2022 avatar Sep 17 '25 12:09 pmenzel2022

I created a new version (v2.16) which uses a newer version of QEMU and restricts to a single core on AMD.

kroese avatar Sep 18 '25 16:09 kroese

I created a new version (v2.16) which uses a newer version of QEMU and restricts to a single core on AMD.

Thank you. However this is a workaround. We hope someone will fix this in the future. Please, advise that this is a temporal feature.

lars18th avatar Sep 19 '25 06:09 lars18th

Yes it is a temporary fix, but I have no AMD CPU's at home (only Intel) so I cannot test if other solutions work. Let's hope somebody else finds a fix.

kroese avatar Sep 19 '25 07:09 kroese

I have only tested on AMD Ryzen 7 5800X but I can test on bare metal linux installs for Ryzen 9 9950X and 5950X and Windows WSL with a Ryzen 7 9700X. I have tried most of the no TSX CPU types and Skylake-Client-v4 hits all the requested flag options to boot and run well.

  macos:
    image: dockurr/macos
    container_name: macos
    environment:
      RAM_SIZE: "16G"
      CPU_CORES: "4"
      CPU_MODEL: "Skylake-Client-v4"
      VERSION: "15"
      FORCE: "Y"
    devices:
      - /dev/kvm
      - /dev/net/tun
    cap_add:
      - NET_ADMIN
    ports:
      - 8007:8006
      - 5900:5900/tcp
      - 5900:5900/udp
    volumes:
      - /opt/macos:/storage
    restart: always
    stop_grace_period: 2m  
Image

piaccarino avatar Sep 19 '25 13:09 piaccarino

@piaccarino Does it run better with "Skylake-Client-v4" then with the default ( "Haswell-noTSX" )? Because in that case maybe we should change the default.

kroese avatar Oct 14 '25 08:10 kroese

@piaccarino Does it run better with "Skylake-Client-v4" then with the default ( "Haswell-noTSX" )? Because in that case maybe we should change the default.

Haswell-noTSX is a little bit faster but I experienced more segfaults and boot crashes probably because I upgraded to Tahoe. I do not experience them with Skylake-Client-v4 and it could be due to additional instruction sets. Completely unscientific assessment.

piaccarino avatar Oct 14 '25 12:10 piaccarino

@piaccarino What does the FORCE: "Y" env var do? Can't find any documentation for that.

Update: Nevermind. Found that it bypasses the CPU core limit.

wiknew1 avatar Oct 29 '25 09:10 wiknew1