尝试在Centos(Rhel 7.5)上运行google-chrome时无法打开X显示屏

vnjpjtjt  于 2022-11-07  发布在  Go
关注(0)|答案(5)|浏览(205)

我需要使用SSH在虚拟机上远程运行Google Chrome。我不想使用xforwarding -我想利用虚拟机上可用的GPU。当我尝试运行google-chrome时,我得到以下错误:

[19615:19615:0219/152933.751028:ERROR:browser_main_loop.cc(1512)] Unable to open X display.

我尝试将DISPLAY env值设置为不同的值:

export DISPLAY=localhost:0.0
export DISPLAY=127.0.0.1:0.0
export DISPLAY=:0.0

我还尝试用不同的值替换上面例子中的0.0。
我在/etc/ssh/sshd_config中有ForwardX11 no,我尝试如下设置目标:

systemctl isolate multi-user.target

当我尝试运行sudo lshw -C display时,我得到以下输出:


* -display

       description: VGA compatible controller
       product: Hyper-V virtual VGA
       vendor: Microsoft Corporation
       physical id: 8
       bus info: pci@0000:00:08.0
       version: 00
       width: 32 bits
       clock: 33MHz
       capabilities: vga_controller bus_master rom
       configuration: driver=hyperv_fb latency=0
       resources: irq:11 memory:f8000000-fbffffff
  *-display UNCLAIMED
       description: VGA compatible controller
       product: GM204GL [Tesla M60]
       vendor: NVIDIA Corporation
       physical id: 1
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vga_controller bus_master cap_list
       configuration: latency=0
       resources: iomemory:f0-ef iomemory:f0-ef memory:41000000-41ffffff memory:fe0000000-fefffffff memory:ff0000000-ff1ffffff

我尝试通过以下方式更新我的GPU驱动程序:

wget https://www.nvidia.com/content/DriverDownload-March2009/confirmation.php?url=/tesla/375.66/nvidia-diag-driver-local-repo-rhel7-375.66-1.x86_64.rpm
yum -y install nvidia-diag-driver-local-repo-rhel7-375.66-1.x86_64.rpm

但在那之后,我仍然看到UNCLIMED旁边我的NVIDIA gpu. Aby的想法?

uxh89sit

uxh89sit1#

您可以尝试使用Xvfb。它不需要额外的硬件。

如果您尚未安装Xvfb,请安装它并执行以下步骤。

sudo apt-get install -y xvfb

使“无头”铬/ selenium 工作的依赖性:

sudo apt-get -y install xorg xvfb gtk2-engines-pixbuf
sudo apt-get -y install dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable

可选但很漂亮:用于捕获Xvfb显示屏的屏幕截图:

sudo apt-get -y install imagemagick x11-apps

确保Xvfb在每次启动box/vm时启动:

Xvfb -ac :99 -screen 0 1280x1024x16 &
export DISPLAY=:99

运行谷歌浏览器

google-chrome
8yoxcaq7

8yoxcaq72#

好了,伙计们。我在疯狂了2个小时后发现了我的问题。我的盒子配置正确。你不能做的是,ssh从一个盒子,到另一个盒子,到这个盒子,并期望X11转发能很好地发挥作用。在不撕裂整个网络的情况下,我发现如果我从主盒子到这个盒子(没有双重或三重ssh“ing)chrome作为一个普通用户使用CLI。所以这是一个来自多个盒子的多个shell的问题,使显示器说它被设置为什么都没有!手动设置显示器只会使问题复杂化。一旦我直接从主外盒壳到这个盒子,我的显示器被设置为10:0,这是我配置中的第一个示例。不要犯这个错误,你会浪费宝贵的时间。

j8ag8udp

j8ag8udp3#

FWIW,我在使用SSH登录Docker编写堆栈中的Selenium chrome节点时遇到了这个问题。如果我以sudo -u seluser google-chrome的身份调用chrome,Chrome会启动,但如果我以seluser的身份登录,chrome就不会启动。窍门是rootDISPLAY设置为:99:0,而seluser根本没有设置它。如果我显式地设置它(从seluser shell或从docker compose exec命令行),它就可以工作。

$ docker-compose exec -u seluser \
  selenium-chrome \                 # or whatever your service is called
  /bin/bash
seluser@c02cda62b751:/$ export DISPLAY=:99:0
seluser@c02cda62b751:/$ google-chrome http://app.test:3000/home

$ docker-compose exec -u seluser -e DISPLAY=:99:0 \
  selenium-chrome \
    google-chrome http://app.test:3000/home

但是:99.0没有文档记录,所以如果这样做不起作用,可以尝试使用以下语句检查rootDISPLAY值:

docker-compose exec -u root selenium-chrome bash -c 'echo "${DISPLAY}"'
unhi4e5o

unhi4e5o4#

我在WSL和Ubuntu上遇到了同样的问题。我卸载/重置了ubuntu。之后,我执行了下面的命令

wsl --set-default-version 2

然后我又安装了Ubuntu,我没有遇到--no-sandbox问题或任何问题。
希望这会对某人有用。

oxf4rvwz

oxf4rvwz5#

这些决议没有一个对我起作用;我有一个新的WSL 2安装在Win 11上,Debian Distro。
尝试打开Cypress.io GUI,但由于缺少DRI 3支持而无法打开。我已经安装了xvfb,但即使这样我也无法打开chrome。

相关问题