google / android-emulator-container-scripts

Apache License 2.0
1.89k stars 267 forks source link

Emulator attached GPU but not use GPU at all #353

Open pnthai88 opened 1 year ago

pnthai88 commented 1 year ago

Hello,

I'm facing strange issue. Emulators connected GPU but these vms does not use GPU. image

My GPU driver setup in host:

1./ sudo apt-get purge nvidia-*
2./ sudo add-apt-repository ppa:graphics-drivers/ppa
3./ sudo apt-get update
4./ sudo apt-get install nvidia-driver-535
5./ sudo reboot
.
.
.
6./ nvidia-smi (check nvidia driver installed)
7./ curl https://get.docker.com | sh \
  && sudo systemctl --now enable docker
8./ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
      && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
      && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
            sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
            sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
9./ sudo apt-get update
10./ sudo apt-get install -y nvidia-container-toolkit
11./ sudo nvidia-ctk runtime configure --runtime=docker
12./ sudo systemctl restart docker

My inside container setup

....
# Install required packages
RUN apt-get update \
    && apt-get install -y \
    vulkan-tools \
    vulkan-utils \
    libnvidia-gl-535
...

Trying to start container

###### emulator @emulator-5554 -cores 2 -gpu host ######
INFO    | Android emulator version 32.1.14.0 (build_id 10330179) (CL:N/A)
INFO    | Found systemPath /opt/android/system-images/android-29/google_apis/x86_64/
INFO    | Storing crashdata in: /tmp/android-unknown/emu-crash.db, detection is enabled
INFO    | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
WARNING | Please update the emulator to one that supports the feature(s): Vulkan
WARNING | cannot add library /opt/android/emulator/qemu/linux-x86_64/lib64/vulkan/libvulkan.so: failed
INFO    | added library /opt/android/emulator/lib64/vulkan/libvulkan.so
host doesn't support requested feature: CPUID.80000001H:ECX.abm [bit 5]
host doesn't support requested feature: CPUID.80000001H:ECX.abm [bit 5]
pulseaudio: pa_context_connect() failed
pulseaudio: Reason: Connection refused
pulseaudio: Failed to initialize PA contextCould not init `pa' audio driver
WARNING | *** No gRPC protection active, consider launching with the -grpc-use-jwt flag.***
INFO    | Started GRPC server at 127.0.0.1:8554, security: Local, auth: none
WARNING | Using fallback path for the emulator registration directory.
WARNING | .ini File /root/.android/avd/running/288 too large (9223372036854775807 bytes)
INFO    | Advertising in: /root/.android/avd/running/pid_2707.ini
WARNING | Using fallback path for the emulator registration directory.
WARNING | .ini File /root/.android/avd/running/288 too large (9223372036854775807 bytes)
WARNING | .ini File /root/.android/avd/running/288 too large (9223372036854775807 bytes)
INFO    | Setting display: 0 configuration to: 1080x1920, dpi: 480x480 

i take focus on this log, it seem not correct, i tried to use "sdkmanager --update" but no help

WARNING | Please update the emulator to one that supports the feature(s): Vulkan
WARNING | cannot add library /opt/android/emulator/qemu/linux-x86_64/lib64/vulkan/libvulkan.so: failed
INFO    | added library /opt/android/emulator/lib64/vulkan/libvulkan.so

The container started successfully, i see it listed in nvidia-smi on host image

But it did not listed inside container... image

I think it's problem to use GPU. How can i solve this problem to able to use GPU to gain higher performance ?

Thanks, BR.