GPU加速铬


11

我正在运行Xubuntu 12.04的全新安装,我想知道如何在最新的稳定Chromium中激活nVidia卡的GPU加速。我想在不将CPU触发到100%的情况下播放MP4文件。

我已经安装了mplayer和vdpau(它们可以正常工作),但是到目前为止,我还不能在Chromium中使用它们。几年前,我使用了gecko-mediaplayer,但是该插件已被列入黑名单...

有任何想法吗?

这是的输出glxinfo | grep render

direct rendering: Yes
OpenGL renderer string: GeForce GT 520M/PCIe/SSE2
    GL_NV_blend_square, GL_NV_compute_program5, GL_NV_conditional_render, 
    GL_NV_parameter_buffer_object2, GL_NV_path_rendering, 
    GL_NVX_conditional_render, GL_NVX_gpu_memory_info, 

这是输出lspci | grep -i vga

02:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 520M] (rev a1)

每当我打开页面时,Chromium都会发出很多警告,正如您在此处看到的那样,我刚刚发现了一个有希望的领先者,却迷失在性能警告中:

NVIDIA: could not open the device file /dev/nvidia0 (Operation not permitted).

将用户添加到视频组后,Chromium现在完全无法播放MP4(是的,甚至不使用CPU)。我收到了与以前相同的错误消息,但同时弹出了一个新消息:

[4296:4296:0827/100001:ERROR:gpu_video_decode_accelerator.cc(208)]在无效内容中未实现:: GpuVideoDecodeAccelerator :: Initialize(media :: VideoCodecProfile,IPC :: Message *)** HW视频解码加速不可用**。

为什么您的CPU使用率上升到100%?即使没有任何HWA(没有GPU),我也可以通过Google Chrome浏览器播放mp4视频,CPU使用率不到20%。

4
在使用4年的300美元计算机上播放1080p视频。
若奥·佩雷拉

Answers:


7

TL; DR:除非您尝试了下面的所有操作,而现在黑屏击中了此特定的已修复的 bug,则现在应该解决您的问题。如果您现在得到:

ERROR:gpu_video_decode_accelerator.cc(208)] Not implemented reached in void content::GpuVideoDecodeAccelerator::Initialize(media::VideoCodecProfile, IPC::Message\*) HW video decode acceleration not available.

在尝试了以下所有内容之后,您应该尝试使用--disable-gpu-sandbox或启动Chrome / ium --blacklist-accelerated-compositing。如果问题仍然存在,请还原所有更改并报告错误,详细说明问题是什么,您尝试了什么以及所有可能的数据:about:gpu,,about:version正在使用的驱动程序,内核版本等。对于仍要测试其驱动程序的驱动程序运气,请使用前面提到的开关,但确实存在AMD卡问题,“强制Chrome / ium使用HWA”部分适用于您。那些使用Nvidia私有驱动程序或xorg-ppa-edge的用户,应该使用Firefox进行测试,看看问题是否也在那里发生了。

Nvidia权限问题

NVIDIA:无法打开设备文件/ dev / nvidia0(不允许操作)。

这意味着您不属于该video组。您可以轻松地解决此问题:

sudo adduser Hal video

然后重新启动会话,您就在那里。

来源:http : //forums.gentoo.org/viewtopic-p-7232328.html?sid=900a2d59cdb52e1a5f530598dfa1be24#7232328

强制Chrome / ium使用HWA

您应该about:gpu在Chrome / ium中检查您的部分。在较旧的PC中,硬件加速默认情况下是禁用的,您只能通过覆盖中的设置来启用它about:flags

  • about:flags在您的地址栏中打开
  • 查找替代软件的重新发布列表
  • 点击“启用”
  • 重新启动Chrome / ium

您也可以使用来启动chrome,chrome --ignore-gpu-blacklist但每次都这样做并非理想。

这是我的GPU页面

这是我的旗帜


1
好吧,我在chrome:// gpu中启用了“替代软件渲染列表”,重新打开了Chrome,并打开了一个包含HTML5嵌入视频标签(源为MP4)的本地页面,但CPU的运行状况仍超过100%。然后,我安装了gecko-mediaplayer,重新启动并使用ignore blacklist参数重新打开了Chrome,但也没有这样的运气。还有其他想法吗?我的图形特征状态与您相同。
若奥·佩雷拉

我不确定视频解码是否真的有效。我在Ubuntu 12.04上运行Chrome 29,并且看到“ Mac和Linux上无法使用加速视频解码。:137247,133828”,所以我很惊讶地看到您将其升级为“硬件加速”。
gertvdijk

现在,如果我们能提高Chromium把他的钱,他的嘴...
若奥·佩雷拉

1
@Braiam对不起,如果我不太清楚,它也会为我显示,但似乎不起作用,如“检测到问题”输出中所示(禁用强制选项时)。参见错误报告(code.google.com/p/chromium/issues/detail?id=137247
gertvdijk

1
@gertvdijk是的,我以前看过那个报告。实际上,这是一个相当愚蠢的愚蠢政策:我们不喜欢错误报告,因此我们(真的)缓慢地激活我们认为没有问题的卡(少数),并让拥有卡的用户正常工作仅以实际表现的0.1%运行。
Braiam

0

在linux / chromium上进行视频解码的解决方案:

铬linux代码中的GpuVideoDecodeAccelerator功能已禁用了几个月(显然​​不是ChromiumOS除外),因此您必须像这样修补铬:

https://bazaar.launchpad.net/~saiarcot895/chromium-browser/chromium-browser.utopic.beta/view/head:/debian/patches/enable_vaapi_on_linux.diff

或使用这个很棒的PPA:

https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-beta

在Intel SandyBridge上针对H264在libva上进行了测试,效果很好。不了解VP8。

根据要求,这里是完整补丁:

Index: beta.vivid/content/common/gpu/media/gpu_video_decode_accelerator.cc
===================================================================
--- beta.vivid.orig/content/common/gpu/media/gpu_video_decode_accelerator.cc    2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/common/gpu/media/gpu_video_decode_accelerator.cc 2014-12-04 09:32:45.341607169 -0500
@@ -31,7 +31,7 @@
 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11)
 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h"
 #include "content/common/gpu/media/v4l2_video_device.h"
-#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11)
+#elif (defined(OS_CHROMEOS) || defined(OS_LINUX)) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11)
 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
 #include "ui/gl/gl_context_glx.h"
 #include "ui/gl/gl_implementation.h"
@@ -272,7 +272,7 @@
       make_context_current_,
       device.Pass(),
       io_message_loop_));
-#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11)
+#elif (defined(OS_CHROMEOS) || defined(OS_LINUX)) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11)
   if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) {
     VLOG(1) << "HW video decode acceleration not available without "
                "DesktopGL (GLX).";
Index: beta.vivid/content/content_common.gypi
===================================================================
--- beta.vivid.orig/content/content_common.gypi 2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/content_common.gypi  2014-12-04 09:32:45.341607169 -0500
@@ -769,7 +769,7 @@
         '<(DEPTH)/third_party/khronos',
       ],
     }],
-    ['target_arch != "arm" and chromeos == 1 and use_x11 == 1', {
+    ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1) and use_x11 == 1', {
       'dependencies': [
         '../media/media.gyp:media',
         '../third_party/libyuv/libyuv.gyp:libyuv',
Index: beta.vivid/content/content_gpu.gypi
===================================================================
--- beta.vivid.orig/content/content_gpu.gypi    2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/content_gpu.gypi 2014-12-04 09:32:45.341607169 -0500
@@ -40,7 +40,7 @@
         ],
       },
     }],
-    ['target_arch!="arm" and chromeos == 1', {
+    ['target_arch!="arm" and (chromeos == 1 or desktop_linux == 1)', {
       'include_dirs': [
         '<(DEPTH)/third_party/libva',
       ],
Index: beta.vivid/content/content_tests.gypi
===================================================================
--- beta.vivid.orig/content/content_tests.gypi  2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/content_tests.gypi   2014-12-04 09:32:45.342607150 -0500
@@ -1556,7 +1556,7 @@
           },
         ]
     }],
-    ['chromeos==1 and use_x11 == 1 and target_arch != "arm"', {
+    ['(chromeos==1 or desktop_linux==1) and use_x11 == 1 and target_arch != "arm"', {
       'targets': [
           {
             'target_name': 'vaapi_h264_decoder_unittest',
Index: beta.vivid/content/public/common/content_switches.cc
===================================================================
--- beta.vivid.orig/content/public/common/content_switches.cc   2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/public/common/content_switches.cc    2014-12-04 09:32:45.342607150 -0500
@@ -930,7 +930,7 @@
 // Disable web audio API.
 const char kDisableWebAudio[]               = "disable-webaudio";

-#if defined(OS_CHROMEOS)
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
 // Disables panel fitting (used for mirror mode).
 const char kDisablePanelFitting[]           = "disable-panel-fitting";

Index: beta.vivid/content/public/common/content_switches.h
===================================================================
--- beta.vivid.orig/content/public/common/content_switches.h    2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/public/common/content_switches.h 2014-12-04 09:32:45.342607150 -0500
@@ -268,7 +268,7 @@

 CONTENT_EXPORT extern const char kDisableWebAudio[];

-#if defined(OS_CHROMEOS)
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
 CONTENT_EXPORT extern const char kDisablePanelFitting[];
 CONTENT_EXPORT extern const char kDisableVaapiAcceleratedVideoEncode[];
 #endif
Index: beta.vivid/media/media.gyp
===================================================================
--- beta.vivid.orig/media/media.gyp 2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/media/media.gyp  2014-12-04 09:32:45.342607150 -0500
@@ -672,7 +672,7 @@
           ],
         }],
         # For VaapiVideoEncodeAccelerator.
-        ['target_arch != "arm" and chromeos == 1 and use_x11 == 1', {
+        ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1) and use_x11 == 1', {
           'sources': [
             'filters/h264_bitstream_buffer.cc',
             'filters/h264_bitstream_buffer.h',
Index: beta.vivid/gpu/config/software_rendering_list_json.cc
===================================================================
--- beta.vivid.orig/gpu/config/software_rendering_list_json.cc  2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/gpu/config/software_rendering_list_json.cc   2014-12-04 09:32:45.343607131 -0500
@@ -508,8 +508,8 @@
     },
     {
       "id": 48,
-      "description": "Accelerated video decode is unavailable on Mac and Linux",
-      "cr_bugs": [137247, 133828],
+      "description": "Accelerated video decode is unavailable on Mac",
+      "cr_bugs": [133828],
       "exceptions": [
         {
           "os": {
@@ -525,6 +525,11 @@
           "os": {
             "type": "android"
           }
+        },
+        {
+          "os": {
+            "type": "linux"
+          }
         }
       ],
       "features": [
Index: beta.vivid/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
===================================================================
--- beta.vivid.orig/content/common/sandbox_linux/bpf_gpu_policy_linux.cc    2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/common/sandbox_linux/bpf_gpu_policy_linux.cc 2014-12-04 09:32:45.343607131 -0500
@@ -21,6 +21,8 @@
 #include "base/logging.h"
 #include "base/memory/scoped_ptr.h"
 #include "build/build_config.h"
+// Auto-generated for dlopen libva libraries
+#include "content/common/gpu/media/va_stubs.h"
 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
 #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h"
 #include "content/common/set_process_title.h"
@@ -30,6 +32,8 @@
 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h"
 #include "sandbox/linux/services/linux_syscalls.h"
 #include "sandbox/linux/syscall_broker/broker_process.h"
+#include "third_party/libva/va/va.h"
+#include "third_party/libva/va/va_x11.h"

 using sandbox::BrokerProcess;
 using sandbox::SyscallSets;
@@ -38,6 +42,14 @@
 using sandbox::bpf_dsl::ResultExpr;
 using sandbox::bpf_dsl::Trap;

+using content_common_gpu_media::kModuleVa;
+using content_common_gpu_media::InitializeStubs;
+using content_common_gpu_media::StubPathMap;
+
+// libva-x11 depends on libva, so dlopen libva-x11 is enough
+static const base::FilePath::CharType kVaLib[] =
+    FILE_PATH_LITERAL("libva-x11.so.1");
+
 namespace content {

 namespace {
@@ -238,19 +250,38 @@
     // Accelerated video dlopen()'s some shared objects
     // inside the sandbox, so preload them now.
     if (IsAcceleratedVideoEnabled()) {
-      const char* I965DrvVideoPath = NULL;
+      StubPathMap paths;
+      paths[kModuleVa].push_back(kVaLib);
+      if (!InitializeStubs(paths)) {
+        return false;
+      }

-      if (IsArchitectureX86_64()) {
-        I965DrvVideoPath = "/usr/lib64/va/drivers/i965_drv_video.so";
-      } else if (IsArchitectureI386()) {
-        I965DrvVideoPath = "/usr/lib/va/drivers/i965_drv_video.so";
+      // libva drivers won't get loaded even above two libraries get dlopened.
+      // Thus, libva calls will fail after post sandbox stage.
+      //
+      // To get the va driver loadded before sandboxing, upstream simply dlopen
+      // the hard-coded va driver path because ChromeOS is the only platform
+      // that Google want to support libva.
+      //
+      // While generic linux distros ship va driver as anywhere they want.
+      // Fortunately, the va driver will be loadded when vaInitialize() get
+      // called.
+      // So the following code is to call vaInitialize() before sandboxing.
+      Display* x_display = XOpenDisplay(NULL);
+      VADisplay va_display = vaGetDisplay(x_display);
+      if (!vaDisplayIsValid(va_display)) {
+        DVLOG(1) << "Failed to call vaGetDisplay()";
+        return false;
       }

-      dlopen(I965DrvVideoPath, RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
-      dlopen("libva.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
-      dlopen("libva-x11.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
-    }
-  }
+      int major_version, minor_version;
+      if (vaInitialize(va_display, &major_version, &minor_version)
+          != VA_STATUS_SUCCESS) {
+        DVLOG(1) << "Failed to call vaInitialize()";
+        return false;
+      }
+    }  // end of IsAcceleratedVideoDecodeEnabled()
+  }  // end of IsArchitectureX86_64() || IsArchitectureI386()

   return true;
 }

1
尽管从理论上讲这可以回答问题,但最好在此处包括答案的基本部分,并提供链接以供参考。
MadMike 2015年

我的意思是包括有关如何获取源代码,应用补丁并进行编译的步骤。或有关如何添加PPA并安装浏览器的信息。
MadMike'3
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.