GPU 服务器重新启动设备时/dev没有NVIDIA设备(No /dev/nvidia* exist);

本文提供了解决Linux系统开机后无法识别NVIDIA设备的问题的两种方法。第一种方法是直接将nvidia-smi命令添加到/etc/rc.local文件中;第二种方法则涉及使用bash脚本启动NVIDIA模块并检查设备数量,从而自动创建相应的设备节点。

问题描述: 开机后/dev/没有nvidia设备(No /dev/nvidia* exist)


解决办法:

方法一:(同时最简单的方法)

echo "nvidia-smi">> /etc/rc.local 


方法二:
#!/bin/bash /sbin/modprobe nvidia 
if [ "$?" -eq 0 ];
then 
# Count the number of NVIDIA controllers found. 
NVDEVS=`lspci | grep -i NVIDIA` 
N3D=`echo "$NVDEVS" | grep "3D controller" | wc -l` 
NVGA=`echo "$NVDEVS" | grep "VGA compatible controller" | wc -l` 

N=`expr $N3D + $NVGA - 1` 
for i in `seq 0 $N`; do 
    mknod -m 666 /dev/nvidia$i c 195 $i 
done 

    mknod -m 666 /dev/nvidiactl c 195 255
 
else
      exit 1 
fi
# 查看详细Xorg日志 tail -n 50 /var/log/Xorg.1.log | grep -iE "(EE|WW)" Error: unable to open display :0 [ 2431.609] (WW) xf86OpenConsole: setpgid failed: Operation not permitted [ 2431.609] (WW) xf86OpenConsole: setsid failed: Operation not permitted [ 2431.609] (WW) Falling back to old probe method for modesetting [ 2431.609] (EE) open /dev/dri/card0: No such file or directory [ 2431.609] (WW) Falling back to old probe method for fbdev [ 2431.609] (EE) open /dev/fb0: No such file or directory [ 2431.609] (WW) Falling back to old probe method for modesetting [ 2431.609] (EE) open /dev/dri/card0: No such file or directory [ 2431.609] (WW) Falling back to old probe method for fbdev [ 2431.609] (EE) open /dev/fb0: No such file or directory [ 2431.609] (EE) No devices detected. [ 2431.609] (EE) [ 2431.609] (EE) no screens found(EE) [ 2431.609] (EE) [ 2431.609] (EE) Please also check the log file at "/var/log/Xorg.1.log" for additional information. [ 2431.609] (EE) [ 2431.609] (EE) Server terminated with error (1). Closing log file. root@srv771551:~# # 使用vesa驱动启动 startx -- -keeptty -verbose 3 -logverbose 6 -novtswitch -config /etc/X11/xorg.conf.d/10-screen.conf # 强制指定显示设备 startx -- vt1 :0 X.Org X Server 1.21.1.11 X Protocol Version 11, Revision 0 Current Operating System: Linux srv771551 6.8.0-60-generic #63-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 15 19:04:15 UTC 2025 x86_64 Kernel command line: BOOT_IMAGE=/vmlinuz-6.8.0-60-generic root=UUID=30964bc7-c7b0-4ada-9642-1f49d6e6c210 ro console=tty0 console=ttyS0,115200 earlyprintk=ttyS0,115200 consoleblank=0 memhp_default_state=online console=tty1 console=ttyS0 xorg-server 2:21.1.12-1ubuntu1.3 (For technical support please see http://www.ubuntu.com/support) Current version of pixman: 0.42.2 Before reporting problems, check http://wiki.x.org to make sure that you have the latest version. Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: "/var/log/Xorg.1.log", Time: Tue May 27 22:10:42 2025 (++) Using config file: "/etc/X11/xorg.conf.d/10-screen.conf" (==) Using config directory: "/etc/X11/xorg.conf.d" (==) Using system config directory "/usr/share/X11/xorg.conf.d" (==) No Layout section. Using the first Screen section. (**) |-->Screen "Default Screen" (0) (**) | |-->Monitor "<default monitor>" (**) | |-->Device "Default Device" (**) | |-->GPUDevice "Default Device" (==) No monitor specified for screen "Default Screen". Using a default monitor configuration. (**) Allowing byte-swapped clients (==) Automatically adding devices (==) Automatically enabling devices (==) Automatically adding GPU devices (==) Automatically binding GPU devices (==) Max clients allowed: 256, resource mask: 0x1fffff (WW) The directory "/usr/share/fonts/X11/cyrillic" does not exist. Entry deleted from font path. (WW) The directory "/usr/share/fonts/X11/100dpi/" does not exist. Entry deleted from font path. (WW) The directory "/usr/share/fonts/X11/75dpi/" does not exist. Entry deleted from font path. (WW) The directory "/usr/share/fonts/X11/100dpi" does not exist. Entry deleted from font path. (WW) The directory "/usr/share/fonts/X11/75dpi" does not exist. Entry deleted from font path. (==) FontPath set to: /usr/share/fonts/X11/misc, /usr/share/fonts/X11/Type1, built-ins (==) ModulePath set to "/usr/lib/xorg/modules" (II) The server relies on udev to provide the list of input devices. If no devices become available, reconfigure udev or disable AutoAddDevices. (II) Loader magic: 0x631a7995f020 (II) Module ABI versions: X.Org ANSI C Emulation: 0.4 X.Org Video Driver: 25.2 X.Org XInput driver : 24.4 X.Org Server Extension : 10.0 (--) using VT number 3 (II) systemd-logind: took control of session /org/freedesktop/login1/session/_38 (II) LoadModule: "glx" (II) Loading /usr/lib/xorg/modules/extensions/libglx.so (II) Module glx: vendor="X.Org Foundation" compiled for 1.21.1.11, module version = 1.0.0 ABI class: X.Org Server Extension, version 10.0 (II) LoadModule: "vesa" (II) Loading /usr/lib/xorg/modules/drivers/vesa_drv.so (II) Module vesa: vendor="X.Org Foundation" compiled for 1.21.1.7, module version = 2.6.0 Module class: X.Org Video Driver ABI class: X.Org Video Driver, version 25.2 (II) VESA: driver for VESA chipsets: vesa (EE) No devices detected. (==) Matched modesetting as autoconfigured driver 0 (==) Matched fbdev as autoconfigured driver 1 (==) Matched vesa as autoconfigured driver 2 (==) Assigned the driver to the xf86ConfigLayout (II) LoadModule: "modesetting" (II) Loading /usr/lib/xorg/modules/drivers/modesetting_drv.so (II) Module modesetting: vendor="X.Org Foundation" compiled for 1.21.1.11, module version = 1.21.1 Module class: X.Org Video Driver ABI class: X.Org Video Driver, version 25.2 (II) LoadModule: "vesa" (II) Loading /usr/lib/xorg/modules/drivers/vesa_drv.so (II) Module vesa: vendor="X.Org Foundation" compiled for 1.21.1.7, module version = 2.6.0 Module class: X.Org Video Driver ABI class: X.Org Video Driver, version 25.2 (II) UnloadModule: "vesa" (II) Unloading vesa (II) Failed to load module "vesa" (already loaded, 0) (II) LoadModule: "fbdev" (II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so (II) Module fbdev: vendor="X.Org Foundation" compiled for 1.21.1.11, module version = 0.5.0 Module class: X.Org Video Driver ABI class: X.Org Video Driver, version 25.2 (II) VESA: driver for VESA chipsets: vesa (II) modesetting: Driver for Modesetting Kernel Drivers: kms (II) FBDEV: driver for framebuffer: fbdev (WW) Falling back to old probe method for modesetting (EE) open /dev/dri/card0: No such file or directory (WW) Falling back to old probe method for fbdev (II) Loading sub module "fbdevhw" (II) LoadModule: "fbdevhw" (II) Loading /usr/lib/xorg/modules/libfbdevhw.so (II) Module fbdevhw: vendor="X.Org Foundation" compiled for 1.21.1.11, module version = 0.0.2 ABI class: X.Org Video Driver, version 25.2 (EE) open /dev/fb0: No such file or directory (WW) Falling back to old probe method for modesetting (EE) open /dev/dri/card0: No such file or directory (WW) Falling back to old probe method for fbdev (II) Loading sub module "fbdevhw" (II) LoadModule: "fbdevhw" (II) Loading /usr/lib/xorg/modules/libfbdevhw.so (II) Module fbdevhw: vendor="X.Org Foundation" compiled for 1.21.1.11, module version = 0.0.2 ABI class: X.Org Video Driver, version 25.2 (EE) open /dev/fb0: No such file or directory (EE) No devices detected. (EE) Fatal server error: (EE) no screens found(EE) (EE) Please consult the The X.Org Foundation support at http://wiki.x.org for help. (EE) Please also check the log file at "/var/log/Xorg.1.log" for additional information. (EE) (EE) Server terminated with error (1). Closing log file. xinit: giving up xinit: unable to connect to X server: Connection refused xinit: server error X.Org X Server 1.21.1.11 X Protocol Version 11, Revision 0 Current Operating System: Linux srv771551 6.8.0-60-generic #63-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 15 19:04:15 UTC 2025 x86_64 Kernel command line: BOOT_IMAGE=/vmlinuz-6.8.0-60-generic root=UUID=30964bc7-c7b0-4ada-9642-1f49d6e6c210 ro console=tty0 console=ttyS0,115200 earlyprintk=ttyS0,115200 consoleblank=0 memhp_default_state=online console=tty1 console=ttyS0 xorg-server 2:21.1.12-1ubuntu1.3 (For technical support please see http://www.ubuntu.com/support) Current version of pixman: 0.42.2 Before reporting problems, check http://wiki.x.org to make sure that you have the latest version. Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: "/var/log/Xorg.0.log", Time: Tue May 27 22:10:57 2025 (==) Using config directory: "/etc/X11/xorg.conf.d" (==) Using system config directory "/usr/share/X11/xorg.conf.d" (EE) Fatal server error: (EE) no screens found(EE) (EE) Please consult the The X.Org Foundation support at http://wiki.x.org for help. (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information. (EE) (EE) Server terminated with error (1). Closing log file.
05-29
# 验证GL渲染器 DISPLAY=:0 glxinfo | grep "OpenGL renderer" # 检查内核消息 dmesg | grep -iE "drm|vga|fb0" Reading package lists... Done Building dependency tree... Done Reading state information... Done E: Unable to locate package libdrm-tools Command 'drm_info' not found, but can be installed with: apt install drm-info Error: unable to open display :0 [ 7.227977] Console: colour VGA+ 80x25 [ 7.654513] vgaarb: loaded [ 8.488129] ACPI: bus type drm_connector registered [ 11.694958] systemd[1]: Starting modprobe@drm.service - Load Kernel Module drm... root@srv771551:~# # 强制使用fbdev驱动 startx -- -config /etc/X11/xorg.conf.d/20-gpu.conf -retro # 使用最低配置模式 Xorg -noreset -keeptty -verbose 3 :0 X.Org X Server 1.21.1.11 X Protocol Version 11, Revision 0 Current Operating System: Linux srv771551 6.8.0-60-generic #63-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 15 19:04:15 UTC 2025 x86_64 Kernel command line: BOOT_IMAGE=/vmlinuz-6.8.0-60-generic root=UUID=30964bc7-c7b0-4ada-9642-1f49d6e6c210 ro console=tty0 console=ttyS0,115200 earlyprintk=ttyS0,115200 consoleblank=0 memhp_default_state=online console=tty1 console=ttyS0 xorg-server 2:21.1.12-1ubuntu1.3 (For technical support please see http://www.ubuntu.com/support) Current version of pixman: 0.42.2 Before reporting problems, check http://wiki.x.org to make sure that you have the latest version. Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: "/var/log/Xorg.0.log", Time: Tue May 27 22:12:19 2025 (++) Using config file: "/etc/X11/xorg.conf.d/20-gpu.conf" (==) Using config directory: "/etc/X11/xorg.conf.d" (==) Using system config directory "/usr/share/X11/xorg.conf.d" (EE) Fatal server error: (EE) no screens found(EE) (EE) Please consult the The X.Org Foundation support at http://wiki.x.org for help. (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information. (EE) (EE) Server terminated with error (1). Closing log file. xinit: giving up xinit: unable to connect to X server: Connection refused xinit: server error X.Org X Server 1.21.1.11 X Protocol Version 11, Revision 0 Current Operating System: Linux srv771551 6.8.0-60-generic #63-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 15 19:04:15 UTC 2025 x86_64 Kernel command line: BOOT_IMAGE=/vmlinuz-6.8.0-60-generic root=UUID=30964bc7-c7b0-4ada-9642-1f49d6e6c210 ro console=tty0 console=ttyS0,115200 earlyprintk=ttyS0,115200 consoleblank=0 memhp_default_state=online console=tty1 console=ttyS0 xorg-server 2:21.1.12-1ubuntu1.3 (For technical support please see http://www.ubuntu.com/support) Current version of pixman: 0.42.2 Before reporting problems, check http://wiki.x.org to make sure that you have the latest version. Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: "/var/log/Xorg.0.log", Time: Tue May 27 22:12:34 2025 (==) Using config directory: "/etc/X11/xorg.conf.d" (==) Using system config directory "/usr/share/X11/xorg.conf.d" (==) No Layout section. Using the first Screen section. (**) |-->Screen "Default Screen" (0) (**) | |-->Monitor "<default monitor>" (**) | |-->Device "Default Device" (**) | |-->GPUDevice "GPU0" (==) No monitor specified for screen "Default Screen". Using a default monitor configuration. (**) Allowing byte-swapped clients (==) Automatically adding devices (==) Automatically enabling devices (==) Automatically adding GPU devices (==) Automatically binding GPU devices (==) Max clients allowed: 256, resource mask: 0x1fffff (WW) The directory "/usr/share/fonts/X11/cyrillic" does not exist. Entry deleted from font path. (WW) The directory "/usr/share/fonts/X11/100dpi/" does not exist. Entry deleted from font path. (WW) The directory "/usr/share/fonts/X11/75dpi/" does not exist. Entry deleted from font path. (WW) The directory "/usr/share/fonts/X11/100dpi" does not exist. Entry deleted from font path. (WW) The directory "/usr/share/fonts/X11/75dpi" does not exist. Entry deleted from font path. (==) FontPath set to: /usr/share/fonts/X11/misc, /usr/share/fonts/X11/Type1, built-ins (==) ModulePath set to "/usr/lib/xorg/modules" (II) The server relies on udev to provide the list of input devices. If no devices become available, reconfigure udev or disable AutoAddDevices. (II) Loader magic: 0x576497426020 (II) Module ABI versions: X.Org ANSI C Emulation: 0.4 X.Org Video Driver: 25.2 X.Org XInput driver : 24.4 X.Org Server Extension : 10.0 (--) using VT number 3 (II) systemd-logind: took control of session /org/freedesktop/login1/session/_38 (II) LoadModule: "glx" (II) Loading /usr/lib/xorg/modules/extensions/libglx.so (II) Module glx: vendor="X.Org Foundation" compiled for 1.21.1.11, module version = 1.0.0 ABI class: X.Org Server Extension, version 10.0 (II) LoadModule: "vesa" (II) Loading /usr/lib/xorg/modules/drivers/vesa_drv.so (II) Module vesa: vendor="X.Org Foundation" compiled for 1.21.1.7, module version = 2.6.0 Module class: X.Org Video Driver ABI class: X.Org Video Driver, version 25.2 (II) LoadModule: "modesetting" (II) Loading /usr/lib/xorg/modules/drivers/modesetting_drv.so (II) Module modesetting: vendor="X.Org Foundation" compiled for 1.21.1.11, module version = 1.21.1 Module class: X.Org Video Driver ABI class: X.Org Video Driver, version 25.2 (II) VESA: driver for VESA chipsets: vesa (II) modesetting: Driver for Modesetting Kernel Drivers: kms (WW) Falling back to old probe method for modesetting (EE) open /dev/dri/card0: No such file or directory (WW) Falling back to old probe method for modesetting (EE) open /dev/dri/card0: No such file or directory (EE) No devices detected. (==) Matched modesetting as autoconfigured driver 0 (==) Matched fbdev as autoconfigured driver 1 (==) Matched vesa as autoconfigured driver 2 (==) Assigned the driver to the xf86ConfigLayout (II) LoadModule: "modesetting" (II) Loading /usr/lib/xorg/modules/drivers/modesetting_drv.so (II) Module modesetting: vendor="X.Org Foundation" compiled for 1.21.1.11, module version = 1.21.1 Module class: X.Org Video Driver ABI class: X.Org Video Driver, version 25.2 (II) UnloadModule: "modesetting" (II) Unloading modesetting (II) Failed to load module "modesetting" (already loaded, 0) (II) LoadModule: "fbdev" (II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so (II) Module fbdev: vendor="X.Org Foundation" compiled for 1.21.1.11, module version = 0.5.0 Module class: X.Org Video Driver ABI class: X.Org Video Driver, version 25.2 (II) LoadModule: "vesa" (II) Loading /usr/lib/xorg/modules/drivers/vesa_drv.so (II) Module vesa: vendor="X.Org Foundation" compiled for 1.21.1.7, module version = 2.6.0 Module class: X.Org Video Driver ABI class: X.Org Video Driver, version 25.2 (II) UnloadModule: "vesa" (II) Unloading vesa (II) Failed to load module "vesa" (already loaded, 0) (II) VESA: driver for VESA chipsets: vesa (II) modesetting: Driver for Modesetting Kernel Drivers: kms (II) FBDEV: driver for framebuffer: fbdev (WW) Falling back to old probe method for modesetting (EE) open /dev/dri/card0: No such file or directory (EE) open /dev/dri/card0: No such file or directory (EE) open /dev/dri/card0: No such file or directory (EE) open /dev/dri/card0: No such file or directory (WW) Falling back to old probe method for fbdev (II) Loading sub module "fbdevhw" (II) LoadModule: "fbdevhw" (II) Loading /usr/lib/xorg/modules/libfbdevhw.so (II) Module fbdevhw: vendor="X.Org Foundation" compiled for 1.21.1.11, module version = 0.0.2 ABI class: X.Org Video Driver, version 25.2 (EE) open /dev/fb0: No such file or directory (WW) Falling back to old probe method for modesetting (EE) open /dev/dri/card0: No such file or directory (EE) open /dev/dri/card0: No such file or directory (EE) open /dev/dri/card0: No such file or directory (EE) open /dev/dri/card0: No such file or directory (WW) Falling back to old probe method for fbdev (II) Loading sub module "fbdevhw" (II) LoadModule: "fbdevhw" (II) Loading /usr/lib/xorg/modules/libfbdevhw.so (II) Module fbdevhw: vendor="X.Org Foundation" compiled for 1.21.1.11, module version = 0.0.2 ABI class: X.Org Video Driver, version 25.2 (EE) open /dev/fb0: No such file or directory (EE) No devices detected. (EE) Fatal server error: (EE) no screens found(EE) (EE) Please consult the The X.Org Foundation support at http://wiki.x.org for help. (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information. (EE) (EE) Server terminated with error (1). Closing log file. root@srv771551:~#
05-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值