我需要在装有 CentOS 的 AWS EC2 GPU 实例上执行一些屏幕外渲染程序。然而,虽然我发现 Ubuntu 很容易设置,但我不能让 CentOS 正常工作。
目标是在EC2 GPU实例上运行一些基本的实用程序/测试工具(没有屏幕或X客户端)。在下面的文章中,我将描述如何设置Ubuntu以及CentOS/Amazon Linux AMI如何失败。
在ubuntu 12.04上,一切都非常顺利。我使用的EC2环境是:
实例启动后,将执行以下命令:
# Install the Nvidia driver
sudo apt-add-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update
sudo apt-get install nvidia-current
# Driver installation needs reboot
sudo reboot now
# Install and configure X window with virtual screen
sudo apt-get install xserver-xorg libglu1-mesa-dev freeglut3-dev mesa-common-dev libxmu-dev libxi-dev
sudo nvidia-xconfig -a --use-display-device=None --virtual=1280x1024
sudo /usr/bin/X :0 &
# OpenGL programs are now workable. Ex. glxinfo, glxgears
DISPLAY=:0 glxinfo
< code>glxgears也可以在后台运行,无需物理屏幕或X客户端:
$ DISPLAY=:0 glxgears
95297 frames in 5.0 seconds = 19059.236 FPS
95559 frames in 5.0 seconds = 19111.727 FPS
94173 frames in 5.0 seconds = 18834.510 FPS
“CentOS”和“Amazon Linux AMI”都源自Red Hat Enterprise Edition。但是,我无法使它们中的任何一个起作用。
几天前,AWS发布了新的G2实例类型。在本文中,建议将带有NVIDIA驱动程序的AmazonLinuxAMI用于Linux平台。在这个AMI中,英伟达驱动程序、X窗口和OpenGL库都已安装。然而,我只是在尝试执行OpenGL程序时收到GLX错误消息。
使用以下设置启动EC2实例:
启动后,重现此问题的步骤非常简单:
sudo X :0 & # Start the X window
glxinfo
glxgears
输出为:
$ glxinfo
name of display: :0
Xlib: extension "GLX" missing on display ":0".
Xlib: extension "GLX" missing on display ":0".
Xlib: extension "GLX" missing on display ":0".
Xlib: extension "GLX" missing on display ":0".
Xlib: extension "GLX" missing on display ":0".
Error: couldn't find RGB GLX visual or fbconfig
Xlib: extension "GLX" missing on display ":0".
Xlib: extension "GLX" missing on display ":0".
Xlib: extension "GLX" missing on display ":0".
Xlib: extension "GLX" missing on display ":0".
Xlib: extension "GLX" missing on display ":0".
$ glxgears
Xlib: extension "GLX" missing on display ":0".
Error: couldn't get an RGB, Double-buffered visual
在/var/log/Xorg.0.log
中发现以下错误:
[139017.484] (EE) Failed to initialize GLX extension (Compatible NVIDIA X driver not found)
我在谷歌上搜索并尝试了许多可能的解决方案,例如:
…但是没有一个有效。
有人对这个问题有具体的解决方案吗?我所说的一切都应该是可复制的(我尝试了很多次)。如果您能提供可复制的说明,让OpenGL (GLX)在带有CentOS/Amazon Linux AMI的EC2 GPU实例上工作,我将不胜感激。
lspci|grep VGA
您应该看到< code>busID是< code>0:3:0。
使用sudo,将它添加到xorg.conf中,如下所示:
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "GRID K520"
BusID "0:3:0"
EndSection
这应该可以修复GLX的失败。
只是一个额外的发现:
我这样做是为了让X服务器运行:
sudo /usr/bin/X :0 &
然而,我的OpenGL应用程序仍然没有使用GPU进行图像渲染,因此速度非常慢。
这救了我——将显示环境变量设置为X服务器正在使用的相同显示(ID: 0 ):
export DISPLAY=:0.0