cuda driver install

heyme·2023년 7월 26일

꾸다 와 도라이바 재설치 과정

  1. 먼저 gui로 사용되는 것을 중지하기 위해 systemctl stop gdm
    GDM은 Linux에서 그래픽 사용자 인터페이스(GUI) 관리하는 역할을 하는데,
    위의 명령어로 GNOME Display Manager(GDM)를 중지한다.
  • NVIDIA 드라이버를 설치하려면 기존의 그래픽 드라이버가 실행 중이면 x
    그래서 먼저 GDM을 중지하여 서버와 관련된 GUI 세션을 종료시킨다.
    systemctl status gdm 이걸로 확인 //Active: inactive로 되어있으면 ok!
● gdm.service - GNOME Display Manager
   Loaded: loaded (/usr/lib/systemd/system/gdm.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Wed 2023-07-26 10:47:05 KST; 30min ago
  Process: 4163259 ExecStopPost=/usr/bin/bash -c for f in /run/systemd/sessions/*; do [ -f $f ] && /usr/b
  Process: 2150 ExecStart=/usr/sbin/gdm (code=exited, status=0/SUCCESS)
 Main PID: 2150 (code=exited, status=0/SUCCESS)
  1. wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
    꾸다와 도라이바를 함께 받고 싶다? cuda toolkit을 받으면 그 버전에 맞는 도라이바도 포함되어 있슴
    출처: https://developer.nvidia.com/cuda-11-8-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Rocky&target_version=8&target_type=runfile_local

  2. 이제 실행을, 그 전에 chmod +x cuda_11.8.0_520.61.05_linux.run 로 권한주기
    chmod +x 명령은 파일에 "실행" 권한을 부여하는 데 사용된다. 여기서 +x는 사용자, 그룹, 그리고 다른 모든 사용자에게 파일의 실행 권한을 추가하는 것을 의미

  3. 실행! ./cuda_11.8.0_520.61.05_linux.run

  4. 몇몇 가지를 물어본다. 이런 것들

(1) 번
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x  End User License Agreement                                                  x
x  --------------------------                                                  x
x                                                                              x
x  NVIDIA Software License Agreement and CUDA Supplement to                    x
x  Software License Agreement. Last updated: October 8, 2021                   x
x                                                                              x
x  The CUDA Toolkit End User License Agreement applies to the                  x
x  NVIDIA CUDA Toolkit, the NVIDIA CUDA Samples, the NVIDIA                    x
x  Display Driver, NVIDIA Nsight tools (Visual Studio Edition),                x
x  and the associated documentation on CUDA APIs, programming                  x
x  model and development tools. If you do not agree with the                   x
x  terms and conditions of the license agreement, then do not                  x
x  download or use the software.                                               x
x                                                                              x
x  Last updated: October 8, 2021.                                              x
x                                                                              x
x                                                                              x
x  Preface                                                                     x
x  -------                                                                     x
x                                                                              x
xqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqx
x Do you accept the above EULA? (accept/decline/quit):                         x
x                                                                              x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
(2) 번
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x CUDA Installer                                                               x
x - [X] Driver                                                                 x
x      [X] 520.61.05                                                           x
x + [X] CUDA Toolkit 11.8                                                      x
x   [X] CUDA Demo Suite 11.8                                                   x
x   [X] CUDA Documentation 11.8                                                x
x - [ ] Kernel Objects                                                         x
x      [ ] nvidia-fs                                                           x
x   Options                                                                    x
x   Install                                                                    x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x Up/Down: Move | Left/Right: Expand | 'Enter': Select | 'A': Advanced options x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
(3) 번
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x A symlink already exists at /usr/local/cuda. Update to this installation?    x
x Yes                                                                          x
x No                                                                           x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x                                                                              x
x Up/Down: Move | 'Enter': Select                                              x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

끝나면 이런 summary를 준다

===========
= Summary =
===========

Driver:   Installed
Toolkit:  Installed in /usr/local/cuda-11.8/

Please make sure that
 -   PATH includes /usr/local/cuda-11.8/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-11.8/lib64, or, add /usr/local/cuda-11.8/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.8/bin
To uninstall the NVIDIA Driver, run nvidia-uninstall
Logfile is /var/log/cuda-installer.log
  1. /root/.bashrc 에 이거 써주기. 근대 도커에서 쓸거니까 거기 배시에 써줘야 한다네..
export PATH=/usr/local/cuda-11.8/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  1. gui 다시 켜주기 systemctl start gdm
  2. nvidia-smi 해보니 잘 나온다! 히히히
    히히히히히히
    히히히히히히히히히히히
    히히히ㅣ히히히히히히ㅣ히ㅣ힣ㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎ

+ 간단한 코드를 통해 잘 설치되었는지 확인해 볼 수 있다

#include <stdio.h>

__global__ void helloFromGPU(void) {
    printf("Hello World from GPU!\n");
}

int main(void) {
    printf("Hello World from CPU!\n");

    helloFromGPU<<<1, 10>>>();
    cudaDeviceReset();

    return 0;
}

nvcc test.cu -o tset 컴파일하고 실행해보면 hello GPU 어쩌구가 10번 나오면 성공

+ 도커도 다 꺼져있네.. 도커도 다시살림 systemctl start docker

+ 진짜 마지막으로 하나 더 추가하자면, 엔비디아 말고 리늑스 자체에서 배포하는 패키지를 받아서 설치할 수도 있다. 앞서 방법은 범용적인 드라이버라면 이건 os 자체에 맞는 드라이버를 주는 거니까 더 최적화 되있는 것인가? 어째든 이런 방법도 있다. 그런데 이건 cuda는 없으니 같이 깔고 싶으면 처음 방법을 더 추천하요
dnf install kmod-nvidia-520.61.05-4.18.0-372.26.1.x86_64
그냥 dnf install nvidia-driver 이렇게 쓰면 최신버전으로 깔림

+ 진짜 최종 마지막으로, 지금까지 사용한 버전을 정리하면

cuda 11.6
python 3.8
torch 1.3 

이렇게 썼는데

cuda 11.8
python 3.10
torch 2.0 

이렇게 요즘은 많이쓰는가봉가

2개의 댓글

comment-user-thumbnail
2023년 7월 26일

잘 봤습니다. 좋은 글 감사합니다.

1개의 답글