본문 바로가기
AI/환경설정

[환경설정] cuda 사용법 - pytorch, cuda, driver version 확인

by TSpoons 2025. 3. 10.

os: ubuntu 20.04(anaconda3)
GPU : NVIDIA RTX A5000
driver : 550.54.14
cuda : 12.4.0

목표

cuda 12.4를 사용하여 cuda 플랫폼을 이용하려고 한다.

0. 기존 cuda 삭제

pytorch-cuda가 11.7로 되어 있어서 11.7로 cuda 설치했더니 안된다.. ㄷ

dpkg -l | grep -i cuda
rc  libcufile-11-6                              1.2.1.4-1                            amd64        Library for GPU Direct Storage with CUDA 11.6

cuda 11.6이 깔려 있네?

export PATH=/usr/local/cuda-11.6/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-11.6/lib64:$LD_LIBRARY_PATH

1. 그래픽카드 호환 드라이버 확인

https://www.nvidia.com/ko-kr/drivers/

최신 정식 NVIDIA 드라이버 다운로드

최신 정식 NVIDIA 드라이버를 다운로드하여 PC 게임 경험을 향상시키고 앱을 더 빠르게 실행하세요.

www.nvidia.com


www.nvidia.com](https://www.nvidia.com/ko-kr/drivers/)

  • A5000 검색 및 OS 선택
chmod +x NVIDIA-Linux-x86_64-550.144.03.run
sudo ./NVIDIA-Linux-x86_64-550.144.03.run
  • "Would you like to install the NVIDIA OpenGL libraries?" → Yes
  • "Would you like to install the NVIDIA 32-bit compatibility libraries?" → 선택 사항 (32비트 프로그램이 필요하면 Yes)
  • "Would you like to run the nvidia-xconfig utility?" → Yes (X 서버 설정 자동 업데이트)
  • Driver Version은 현재 설치되어 있는 드라이버 버전을 의미하고,
  • CUDA Version은 현재 드라이버에서 할 수 있는 가장 최근의 쿠다 버전을 의미한다.

따라서 cuda가 12.4보다 낮은 버전이 깔려 있어도 12.4로 떠있다.
그러면 cuda version을 확인하려면?

CUDA 확인

nvcc -V

아마 안깔려 있을 것이다.

2. 그래픽 드라이버에 맞는 쿠다 toolkit 설치

  • 우리는 12.4를 설치하면 된다.

https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/#cuda-developer-tools

1. CUDA 12.8 Update 1 Release Notes — Release Notes 12.8 documentation

Using long-deprecated cusolverDnPotrf, cusolverDnPotrs, cusolverDnGeqrf, cusolverDnGetrf, cusolverDnGetrs, cusolverDnSyevd, cusolverDnSyevdx, cusolverDnGesvd, and their accompanying bufferSize functions will result in a deprecation warning. The warning can

docs.nvidia.com

 
 

https://developer.nvidia.com/cuda-toolkit-archive

CUDA Toolkit Archive

Previous releases of the CUDA Toolkit, GPU Computing SDK, documentation and developer drivers can be found using the links below. Please select the release you want from the list below, and be sure to check www.nvidia.com/drivers for more recent production

developer.nvidia.com

 

  • 메뉴얼대로 진행
  • continue

- 여기서 주의.. x가 체크 표시와 같다 (처음에 헷갈림)

Driver (550.54.14): CUDA를 사용하기 위해서는 최신 NVIDIA 드라이버가 필요
CUDA Toolkit 12.4: CUDA 개발에 필요한 핵심 구성 요소이므로 설치를 권장
CUDA Demo Suite 12.4: CUDA 예제와 데모를 실행해보고 싶다면 설치
CUDA Documentation 12.4: 로컬에서 문서를 참조하고 싶다면 설치
Kernel Objects (nvidia-fs): GPUDirect Storage를 사용할 계획이 있다면 설치

완료?
아직이다

3. 환경변수 설정

터미널에서 cuda가 기본적으로 세팅이 되려면 다음과 같이 ~/.bashrc 파일에 추가한다.

echo 'export PATH=/usr/local/cuda-12.4/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc

4. pytorch와 호환성 맞추고 쿠다 확인

DECASE 2023을 사용하려면 torch 버전이 2.4.1이므로
https://pytorch.org/get-started/previous-versions/#v241

Previous PyTorch Versions

Installing previous versions of PyTorch

pytorch.org

 

os: ubuntu 20.04(anaconda3)