Skip to content

Nvidia:HowToInstall

NVIDIA Driver 설치 방법에 대하여 정리한다.

WARNING

만약 CUDA를 설치할 계획이 있다면 CUDA Toolkit을 사용하여 드라이버를 설치해야 한다. CUDA 사용 시 드라이버 버전이 맞지 않으면 정상적으로 기동하지 않는 현상이 발생될 수 있다.

How to install NVIDIA in CentOS

CentOS에서 NVIDIA를 설치하는 방법은 아래와 같다:

## 우선, 그래픽모드 종료를 위해 <code>Ctrl + Alt + F2</code>를 입력.
$ /sbin/init 3
$ modprobe -r nouveau

## nouveau가 종료되었는지 확인:
$ lsmod | grep nouv               ## 아무것도 출력되지 않아야 한다!

$ yum install -y kernel-devel gcc
$ chmod +x NVIDIA~.run

How to install NVIDIA in Ubuntu

Ubuntu에서 NVIDIA를 설치하는 방법은 아래와 같다: 1

## ppa:graphics-drivers/ppa: 최신형 nVidia 그래픽 카드 드라이버 지원.
## https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa
$ sudo apt-add-repository -y ppa:graphics-drivers/ppa
$ sudo apt-cache search nvidia

## 설치.
$ sudo apt-get install nvidia-352 nvidia-352-dev

## 재부팅.
$ sudo reboot

또는

$ sudo ubuntu-drivers autoinstall

Troubleshooting

Screen Blanks/Monitor Turns Off

설치 후 검은 화면이 출력된다. 아래와 같이 수동으로 설치하는 방법이 있다.

참고로 필자의 경우 Geforce GTX 750 ti Driver를 사용했고, 정상적으로 설치되지 않아서 아래와 같이 진행했다.

$ sudo apt-get purge nvidia*
$ sudo apt-get purge xserver-xorg-video-nouveau

/etc/modprobe.d/blacklist.conf파일의 마지막에 아래와 같이 추가한다.

blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv

참고로 설치된 모듈 목록은 다음 명령으로 확인하자:

lsmod | grep -i -E '(nouv|vga|nvidia|riva)'

NVIDIA 그래픽 카드가 작동하지 않거나 성능이 좋지 않을 경우 /etc/default/grub파일의 마지막에 아래와 같이 추가한다. 2

## Find it!
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
## And change it to
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"

GRUB를 업데이트 한다.

$ sudo update-grub

(참고로 위의 GRUB설정은 NVIDIA그래픽 카드 드라이버를 설치한 후 원상복귀해도 된다.)

현재 사용하고 있는 그래픽카드 관련 서비스를 종료하고 재부팅한다.

## 관련 서비스가 뭔지 확인한다. -> gdm, gdm3, lightdm 같은 것들
sudo service --status-all

## Stop service.
$ sudo gdm service stop
## or
$ sudo service gdm3 stop
## or
$ sudo service lightdm stop

그래픽카드 드라이버를 설치한 후 xorg.profile를 개인에 맞게 수정하고 재부팅한다.

만약 드래도 화면이 꺼진다면 이곳을 참조하여 아래와 같이 진행해보자.

  1. Switch to the console by using ctrl+alt+F1, or reboot and select recovery mode from the GRUB menu.
  2. Open and edit xorg.conf like this: sudo nano /etc/X11/xorg.conf.
  3. Find the line that says: Section "Screen"
  4. Insert a new line that says: Option "UseDisplayDevice" "DFP".
  5. Save the file. If you had to restart into recovery mode, type reboot, otherwise restart your display using sudo /etc/init.d/gdm restart.3

Bash script in Ubuntu 14.04

#!/bin/bash

if [[ $(id -u) -ne 0 ]]; then
    echo "Please run as root."
    exit 1
fi

apt-get purge -y nvidia*
apt-get purge -y xserver-xorg-video-nouveau

BLACKLIST_PATH=/etc/modprobe.d/blacklist.conf
GRUB_PATH=/etc/default/grub

echo "Update $BLACKLIST_PATH"
echo "blacklist vga16fb"  >> $BLACKLIST_PATH
echo "blacklist nouveau"  >> $BLACKLIST_PATH
echo "blacklist rivafb"   >> $BLACKLIST_PATH
echo "blacklist nvidiafb" >> $BLACKLIST_PATH
echo "blacklist rivatv"   >> $BLACKLIST_PATH

echo "Update $GRUB_PATH"
sed -i.temp 's/^\(GRUB_CMDLINE_LINUX_DEFAULT=.*\)"$/\1 nomodeset"/g' $GRUB_PATH
update-grub

echo "Run reboot."

Next step:

#!/bin/bash

if [[ $(id -u) -ne 0 ]]; then
    echo "Please run as root."
    exit 1
fi

service lightdm stop

if [[ $? -ne 0 ]]; then
    echo "Fail service lightdm stop."
    exit 1
fi

echo "Download NVIDIA Linux driver."
curl -O http://kr.download.nvidia.com/XFree86/Linux-x86_64/361.45.11/NVIDIA-Linux-x86_64-361.45.11.run
if [[ $? -ne 0 ]]; then
    echo "Fail download."
    exit 1
fi

chmod +x NVIDIA-Linux-x86_64-361.45.11.run
./NVIDIA-Linux-x86_64-361.45.11.run

in CentOS

우선 커널을 업데이트 한다.

$ sudo yum update -y
$ sudo yum install -y kernel-devel kernel-headers gcc make

Nouveau가 존재한다면5 Blacklist목록에 추가한다.

  • /etc/default/grub파일의 GRUB_CMDLINE_LINUX속성에 rdblacklist=nouveau아규먼트를 추가한다.
  • /etc/modprobe.d/blacklist.conf파일에 blacklist nouveau를 추가한다.

이제 GRUB를 업데이트하면 된다. 이 방법 또한 두 가지 방법 중 하나를 선택한다. 6

$ sudo grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

커널 패치후 정상적으로 부팅되지 않는 현상

이 경우, NVIDIA 그래픽 드라이버를 다시 설치하면 될 수 있다. 아래와 같은 순서로 진행한다.

  1. grub에 nomodeset옵션을 추가한다.
  2. update-grub를 사용하여 다시 grub를 업데이트 한다.
  3. lightdm 서비스를 중지시킨다.
  4. NVIDIA 그래픽 드라이버를 다시 설치한다.

An alternate method of installing the NVIDIA driver was detected

                                  NVIDIA Accelerated Graphics Driver for Linux-x86_64 (580.105.08)


  An alternate method of installing the NVIDIA driver was detected. (This is usually a package provided by your distributor.) A
  driver installed via that method may integrate better with your system than a driver installed by nvidia-installer.

  Please review the message provided by the maintainer of this alternate installation method and decide how to proceed:

                                  Continue installation                       Abort installation

 The NVIDIA driver provided by Ubuntu can be installed by launching the "Software & Updates" application, and by selecting the
 NVIDIA driver from the "Additional Drivers" tab.

변역:

  • NVIDIA 가속 그래픽 드라이버(Linux-x86_64용)(580.105.08)
  • NVIDIA 드라이버를 설치하는 다른 방법이 감지되었습니다. (일반적으로 배포판에서 제공하는 패키지입니다.)
  • 이 방법으로 설치된 드라이버는 nvidia-installer로 설치된 드라이버보다 시스템과 더 잘 통합될 수 있습니다.
  • 이 대체 설치 방법의 관리자가 제공한 메시지를 검토하고 다음 중 하나를 선택하십시오.
  • Ubuntu에서 제공하는 NVIDIA 드라이버는 "소프트웨어 및 업데이트" 애플리케이션을 실행하고
  • "추가 드라이버" 탭에서 NVIDIA 드라이버를 선택하여 설치할 수 있습니다.

결론만 말하면 그냥 "컨티뉴" 버튼 누르자.

ERROR: An error occurred while performing the step

  ERROR: An error occurred while performing the step: "Building kernel modules". See /var/log/nvidia-installer.log for details.
  • 오류: "커널 모듈 빌드" 단계를 수행하는 동안 오류가 발생했습니다. 자세한 내용은 /var/log/nvidia-installer.log 파일을 참조하십시오.
  ERROR: An error occurred while performing the step: "Checking to see whether the nvidia kernel module was successfully built".
         See /var/log/nvidia-installer.log for details.
  • 오류: "NVIDIA 커널 모듈이 성공적으로 빌드되었는지 확인하는 단계"를 수행하는 동안 오류가 발생했습니다. 자세한 내용은 /var/log/nvidia-installer.log 파일을 참조하십시오.

결론만 말하면 /var/log/nvidia-installer.log 파일을 확인해봐라.

=== error: unrecognized command-line option '-ftrivial-auto-var-init=zero' ===

cc: error: unrecognized command-line option '-ftrivial-auto-var-init=zero'
 290    make[3]: *** [scripts/Makefile.build:243: /tmp/makeself.YWzjR1r1/NVIDIA-Linux-x86_64-580.105.08/kernel/nvidia/nv-platform.o] Error 1
...

해당 기능은 GCC 12 버전 이상이 필요하다. gcc --version 명령으로 확인하자.

Alternatives#GCC 12 항목 참조.

WARNING: Unable to determine the path to install the libglvnd EGL vendor library config files

  WARNING: Unable to determine the path to install the libglvnd EGL vendor library config files. Check that you have pkg-config and the libglvnd development libraries installed, or specify a path with --glvnd-egl-config-path.
  • 경고: libglvnd EGL 벤더 라이브러리 구성 파일의 설치 경로를 확인할 수 없습니다. pkg-config와 libglvnd 개발 라이브러리가 설치되어 있는지 확인하거나 --glvnd-egl-config-path 옵션을 사용하여 경로를 지정하십시오.

Would you like to run the nvidia-xconfig utility to automatically update your X configuration file so that the NVIDIA X driver will be used when you restart X?

  Would you like to run the nvidia-xconfig utility to automatically update your X configuration file so that the NVIDIA X driver will be used when you restart X?  Any pre-existing X configuration file will be backed up.
  • X 재시작 시 NVIDIA X 드라이버가 사용되도록 X 구성 파일을 자동으로 업데이트하는 nvidia-xconfig 유틸리티를 실행하시겠습니까? 기존 X 구성 파일은 백업됩니다.

See also

Favorite site

References


  1. (참고로 이렇게 정상적으로 설치한 후 가상콘솔로 전환시 검은화면(Black screen)만 나오는 현상이 해결되었다) 

  2. 추가된 nomodeset의 자세한 설명은 이곳을 참조. 

  3. LightDM command: sudo service lightdm restart 

  4. How_to_install_Nvidia_drivers_in_CentOS_7_-_Tutorial.pdf 

  5. lsmod | grep nouveau로 확인 가능 

  6. 만약 아래의 grub.cfg파일이 존재하지 않다면 sudo grub2-mkconfig -o /boot/grub2/grub.cfg명령으로 대체하면 된다. 

  7. How_to_install_nvidia_graphic_driver_from_the_Ubuntu_and_Mint.pdf