Fen*_* Lu 6 gpu google-chrome headless docker
我正在尝试在 docker 容器中以 chrome headless(版本:Google Chrome 102.0.5005.61)模式使用 GPU。Bug get next 错误:在容器中执行 cmd:启动容器:
docker run --gpus all --name centos-chrome-gpu1 -it centos-chrome-gpu:v1 /bin/bash
在容器中执行 cmd 来检测 GPU:
chrome --headless --no-sandbox --enable-features=Vulkan,UseSkiaRenderer --use-vulkan=native --enable-unsafe-webgpu --enable-logging --disable-vulkan-fallback-to-gl-for-testing --disable-vulkan-surface --use-angle=vulkan --print-to-pdf=out.pdf 'chrome://gpu'
Run Code Online (Sandbox Code Playgroud)
出现错误:
[root@3298c3aaf37a data]# chrome --headless --no-sandbox --enable-features=Vulkan,UseSkiaRenderer --use-vulkan=native --enable-unsafe-webgpu --enable-logging --disable-vulkan-fallback-to-gl-for-testing --disable-vulkan-surface --use-angle=vulkan --print-to-pdf=out.pdf 'chrome://gpu'
[0529/064825.243304:ERROR:bus.cc(398)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[0529/064825.244022:ERROR:bus.cc(398)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[0529/064825.247593:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
[0529/064825.255679:ERROR:angle_platform_impl.cc(43)] RendererVk.cpp:127 (VerifyExtensionsPresent): Extension not supported: VK_KHR_surface
[0529/064825.256516:ERROR:angle_platform_impl.cc(43)] RendererVk.cpp:127 (VerifyExtensionsPresent): Extension not supported: VK_KHR_xcb_surface
[0529/064825.256673:ERROR:angle_platform_impl.cc(43)] Display.cpp:977 (initialize): ANGLE Display::initialize error 0: Internal Vulkan error (-7): A requested extension is not supported, in ../../third_party/angle/src/libANGLE/renderer/vulkan/RendererVk.cpp, initialize:1446.
[0529/064825.257420:ERROR:gl_surface_egl.cc(852)] EGL Driver message (Critical) eglInitialize: Internal Vulkan error (-7): A requested extension is not supported, in ../../third_party/angle/src/libANGLE/renderer/vulkan/RendererVk.cpp, initialize:1446.
[0529/064825.257477:ERROR:gl_surface_egl.cc(1489)] eglInitialize Vulkan failed with error EGL_NOT_INITIALIZED
[0529/064825.257526:ERROR:gl_ozone_egl.cc(21)] GLSurfaceEGL::InitializeOneOff failed.
[0529/064825.263608:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization
[0529/064825.277845:ERROR:angle_platform_impl.cc(43)] RendererVk.cpp:127 (VerifyExtensionsPresent): Extension not supported: VK_KHR_surface
[0529/064825.277953:ERROR:angle_platform_impl.cc(43)] RendererVk.cpp:127 (VerifyExtensionsPresent): Extension not supported: VK_KHR_xcb_surface
[0529/064825.278040:ERROR:angle_platform_impl.cc(43)] Display.cpp:977 (initialize): ANGLE Display::initialize error 0: Internal Vulkan error (-7): A requested extension is not supported, in ../../third_party/angle/src/libANGLE/renderer/vulkan/RendererVk.cpp, initialize:1446.
[0529/064825.278129:ERROR:gl_surface_egl.cc(852)] EGL Driver message (Critical) eglInitialize: Internal Vulkan error (-7): A requested extension is not supported, in ../../third_party/angle/src/libANGLE/renderer/vulkan/RendererVk.cpp, initialize:1446.
[0529/064825.278192:ERROR:gl_surface_egl.cc(1489)] eglInitialize Vulkan failed with error EGL_NOT_INITIALIZED
[0529/064825.278255:ERROR:gl_ozone_egl.cc(21)] GLSurfaceEGL::InitializeOneOff failed.
[0529/064825.279831:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization
[0529/064825.306604:WARNING:sandbox_linux.cc(376)] InitializeSandbox() called with multiple threads in process gpu-process.
Warning: vkCreateInstance: Found no drivers!
Error: vkCreateInstance failed with VK_ERROR_INCOMPATIBLE_DRIVER
at CheckVkSuccessImpl (../../third_party/dawn/src/dawn/native/vulkan/VulkanError.cpp:88)
at CreateVkInstance (../../third_party/dawn/src/dawn/native/vulkan/BackendVk.cpp:361)
at Initialize (../../third_party/dawn/src/dawn/native/vulkan/BackendVk.cpp:235)
at Create (../../third_party/dawn/src/dawn/native/vulkan/BackendVk.cpp:165)
at operator() (../../third_party/dawn/src/dawn/native/vulkan/BackendVk.cpp:420)
Run Code Online (Sandbox Code Playgroud)
GPU 检测失败:
Graphics Feature Status
Canvas: Software only, hardware acceleration unavailable
Canvas out-of-process rasterization: Disabled
Direct Rendering Display Compositor: Disabled
Compositing: Software only. Hardware acceleration disabled
Multiple Raster Threads: Enabled
OpenGL: Disabled
Rasterization: Software only. Hardware acceleration disabled
Raw Draw: Disabled
Skia Renderer: Enabled
Video Decode: Software only. Hardware acceleration disabled
Video Encode: Software only. Hardware acceleration disabled
Vulkan: Disabled
WebGL: Software only, hardware acceleration unavailable
WebGL2: Software only, hardware acceleration unavailable
WebGPU: Software only, hardware acceleration unavailable
Run Code Online (Sandbox Code Playgroud)
主机存在错误,但运行良好:
[root@ecs-aedd data]# chrome --headless --no-sandbox --enable-features=Vulkan,UseSkiaRenderer --use-vulkan=native --enable-unsafe-webgpu --enable-logging --disable-vulkan-fallback-to-gl-for-testing --disable-vulkan-surface --use-angle=vulkan --print-to-pdf=out.pdf 'chrome://gpu'
[0529/145105.116019:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
[0529/145105.892509:INFO:headless_shell.cc(660)] Written to file out.pdf.
Run Code Online (Sandbox Code Playgroud)
GPU 检测成功:
Graphics Feature Status
Canvas: Hardware accelerated
Canvas out-of-process rasterization: Disabled
Direct Rendering Display Compositor: Disabled
Compositing: Hardware accelerated
Multiple Raster Threads: Enabled
OpenGL: Enabled
Rasterization: Hardware accelerated
Raw Draw: Disabled
Skia Renderer: Enabled
Video Decode: Software only. Hardware acceleration disabled
Video Encode: Software only. Hardware acceleration disabled
Vulkan: Enabled
WebGL: Hardware accelerated
WebGL2: Hardware accelerated
WebGPU: Hardware accelerated
Run Code Online (Sandbox Code Playgroud)
我应该如何解决这个问题才能在容器中成功检测?
小智 0
我遇到了同样的问题,直到我详细阅读了文档。
我认为你需要添加-e "NVIDIA_DRIVER_CAPABILITIES=all"安装驱动程序
这是我使用的命令
sudo docker run \
--runtime=nvidia --gpus all \
-e "NVIDIA_DRIVER_CAPABILITIES=all" \
-dt \
-p 3000:3000 \
browserless/chrome
Run Code Online (Sandbox Code Playgroud)
我正在使用 AWS EC2 机器
这是我运行的配置主机的命令
# Install driver
sudo apt-get install linux-headers-$(uname -r)
export distribution=$(. /etc/os-release;echo $ID$VERSION_ID | sed -e 's/\.//g')
wget https://developer.download.nvidia.com/compute/cuda/repos/$distribution/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt-get update
sudo apt-get -y install cuda-drivers
# Install nvidia container toolkit
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
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
# Install docker
curl https://get.docker.com | sh \
&& sudo systemctl --now enable docker
# Configure nvidia runtime for docker
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
# Run your container
sudo docker run \
--runtime=nvidia --gpus all \
-e "NVIDIA_DRIVER_CAPABILITIES=all" \
-dt \
-p 3000:3000 \
browserless/chrome
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3654 次 |
| 最近记录: |