您当前的位置:首页 > 计算机 > 系统应用 > Linux

archlinux 安装 nvidia 驱动

时间:12-14来源:作者:点击数:
CDSY,CDSY.XYZ

查看 nvida 网卡型号

dmesg |grep -i nvidia
[    3.092611] nouveau 0000:01:00.0: NVIDIA GF117 (0d7000a2)

这里可以看出我们的 nvida 网卡型号为 GF117

根据网卡型号查询 code name

去 这里(nouveau.freedesktop 组织网/wiki/CodeNames/) 搜索 GF117,有结果:

nvidia-01.png

可以看出对应的 Code name 是 NVD7

根据 codename 查询 archlinux 上对应的驱动包

根据 archwiki(wiki.archlinux 组织网/index.php/NVIDIA) 中的说明, NVDx 系的网卡对应的安装包为 nvidia-390xx

pacman -Ss nvidia-390xx
extra/nvidia-390xx 390.67-4
    NVIDIA drivers for linux, 390xx legacy branch
extra/nvidia-390xx-dkms 390.67-4
    NVIDIA driver sources for linux, 390xx legacy branch
extra/nvidia-390xx-lts 1:390.67-1
    NVIDIA drivers for linux-lts, 390xx legacy branch
extra/nvidia-390xx-settings 390.67-2
    Tool for configuring the NVIDIA graphics driver, 390xx legacy branch
extra/nvidia-390xx-utils 390.67-2
    NVIDIA drivers utilities
extra/opencl-nvidia-390xx 390.67-2
    OpenCL implemention for NVIDIA

其中 nvidia-390xx 对应 linux kernelnvida-390xx-lts 对应 linux-lts kernelnvidia-390xx-dkms 对应其 他自编译的linux kernel

我这里用的只是普通的 linux kernel,因此直接安装 nvidia-390xx 即可

sudo pacman -S nvidia-390xx nvidia-390xx-settings nvidia-390xx-utils --noconfirm
resolving dependencies...
looking for conflicting packages...

Packages (1) nvidia-390xx-390.67-4

Total Installed Size:  9.21 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n] 
(0/1) checking keys in keyring                     [----------------------]   0%(1/1) checking keys in keyring                     [######################] 100%
(0/1) checking package integrity                   [----------------------]   0%(1/1) checking package integrity                   [######################] 100%
(0/1) loading package files                        [----------------------]   0%(1/1) loading package files                        [######################] 100%
(0/1) checking for file conflicts                  [----------------------]   0%(1/1) checking for file conflicts                  [######################] 100%
(0/1) checking available disk space                [----------------------]   0%(1/1) checking available disk space                [######################] 100%
:: Processing package changes...
(1/1) reinstalling nvidia-390xx                    [----------------------]   0%(1/1) reinstalling nvidia-390xx                    [----------------------]   0%(1/1) reinstalling nvidia-390xx                    [----------------------]   0%(1/1) reinstalling nvidia-390xx                    [----------------------]   0%(1/1) reinstalling nvidia-390xx                    [----------------------]   0%(1/1) reinstalling nvidia-390xx                    [----------------------]   0%(1/1) reinstalling nvidia-390xx                    [----------------------]   0%(1/1) reinstalling nvidia-390xx                    [----------------------]   0%(1/1) reinstalling nvidia-390xx                    [----------------------]   0%(1/1) reinstalling nvidia-390xx                    [----------------------]   0%(1/1) reinstalling nvidia-390xx                    [----------------------]   0%(1/1) reinstalling nvidia-390xx                    [----------------------]   0%(1/1) reinstalling nvidia-390xx                    [######################] 100%
:: Running post-transaction hooks...
(1/2) Updating linux module dependencies...
(2/2) Arming ConditionNeedsUpdate...

DRM kernel mode 设置

添加 nvidia-drm.modeset=1 到 kernel 的启动参数中

修改 /etc/default/grub,为 GRUB_CMDLINE_LINUX_DEFAULT 行添加参数 resume=/dev/sda2

sudo sed -i '/GRUB_CMDLINE_LINUX_DEFAULT/ s!"$! nvidia-drm.modeset=1"!' /etc/default/grub

添加 nvidia,nvidia_modeset,nvidia_uvm,nvidia_drm 到 initramfs module 中

修改 /etc/mkinitcpio.conf 文件,在 HOOKS 中添加 resume

sudo sed -i '/^MODULES=/ s/)/ nvidia nvidia_modeset nvidia_uvm nvidia_drm)/' /etc/mkinitcpio.conf 

重新生成 initramfs

sudo mkinitcpio -g /boot/initramfs-linux.img
==> Starting build: 4.17.3-1-ARCH
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [autodetect]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux.img
==> Image generation successful

添加 pacman hook

由于每次更新 nvidia 驱动都需要重新运行 mkinitcpio,因此最好通过 pacman hook 来自动运行

[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=nvidia-390xx

[Action]
Depends=mkinitcpio
When=PostTransaction
Exec=/usr/bin/mkinitcpio -P

使用 bumblebee

1、安装 bumblebee

sudo pacman -S bumblebee --noconfirm
resolving dependencies...
looking for conflicting packages...

Packages (1) bumblebee-3.2.1-17

Total Installed Size:  0.12 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n] 
(0/1) checking keys in keyring                     [----------------------]   0%(1/1) checking keys in keyring                     [######################] 100%
(0/1) checking package integrity                   [----------------------]   0%(1/1) checking package integrity                   [######################] 100%
(0/1) loading package files                        [----------------------]   0%(1/1) loading package files                        [######################] 100%
(0/1) checking for file conflicts                  [----------------------]   0%(1/1) checking for file conflicts                  [######################] 100%
(0/1) checking available disk space                [----------------------]   0%(1/1) checking available disk space                [######################] 100%
:: Processing package changes...
(1/1) reinstalling bumblebee                       [----------------------]   0%(1/1) reinstalling bumblebee                       [######################] 100%
:: Running post-transaction hooks...
(1/4) Reloading system manager configuration...
(2/4) Creating system user accounts...
(3/4) Reloading device manager configuration...
(4/4) Arming ConditionNeedsUpdate...

2、添加当前用户到 bumblebee 组

sudo gpasswd -a ${USER} bumblebee
Adding user lujun9972 to group bumblebee

3、修改 /etc/bumblebee/bumblebee.conf

将 Driver= 修改为 Driver=nvidia 将 KernelDriver=nouveau 修改为 KernelDriver=nvidia

4、启用 bumblebeed.service

sudo systemctl enable bumblebeed
sudo systemctl start bumblebeed

检查 GPU 状态

nvidia-smi
Wed Jun 27 07:17:30 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.67                 Driver Version: 390.67                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  NVS 5200M           Off  | 00000000:01:00.0 N/A |                  N/A |
| N/A   46C    P0    N/A /  N/A |      0MiB /   964MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0                    Not Supported                                       |
+-----------------------------------------------------------------------------+
CDSY,CDSY.XYZ
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐