본문 바로가기
프로그래밍 언어/python 관련

[python] cuda/pytorch 설치

by code cleaner 2019. 7. 23.
반응형

1. cuda는 왜 써야 할까?

CUDA ("Compute Unified Device Architecture", 쿠다)는 그래픽 처리 장치(GPU)에서 수행하는 (병렬 처리) 알고리즘을 C 프로그래밍 언어를 비롯한 산업 표준 언어를 사용하여 작성할 수 있도록 하는 GPGPU 기술이다.

-위키디피아 참조-

프로그래밍을 하면서 특히 분석 모델 학습시 시간을 단축하기 위해 사용할 수 있다.

나의 경우 pytorch에서 cuda 버전으로 설치하기 위해 늦게나마 설치하게 되었다.

 

 

2. cuda 설치하기

 2-1. 내 컴퓨터에 그래픽카드 있는지 확인하기

cuda는 NVIDIA 에서 개발을 해서 NVIDIA의 그래픽 카드가 있어야한다.

컴퓨터에 NVIDIA  GERORCE GTX가 붙어있거나 컴퓨터 사양 검색을 했을 떄, 그래픽카드가 있으면 설치 가능 

 

2-2. 설치하기

 

설치 다운로드 링크 => 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

위의 링크에서 릴리스된 버전을 클릭하고, 나의 컴퓨터에 맞게 설정하여 설치 파일을 다운로드한다.

 

 

'cuda_10.1.105_418.96_win10.exe' 파일 다운로드되고, 클릭하여 실행

 

2-2. 설치 확인하기

 

윈도우키 => cmd 엔터

 

nvcc --version 을 찍으면 설치된 버전 확인이 가능하다

 

 

3. 파이토치 설치하기

 

파이토치 설치 설명 => https://pytorch.org/get-started/locally/

 

 

PyTorch

An open source deep learning platform that provides a seamless path from research prototyping to production deployment.

pytorch.org

 

case1 : 파이썬 설치환경이 아나콘다라면,

pip3 install https://download.pytorch.org/whl/cu100/torch-1.1.0-cp37-cp37m-win_amd64.whl

case2: pip라면

pip3 install https://download.pytorch.org/whl/cu100/torch-1.1.0-cp37-cp37m-win_amd64.whl
pip3 install https://download.pytorch.org/whl/cu100/torchvision-0.3.0-cp37-cp37m-win_amd64.whl

case 나의 경우는 pip3가 없고, 다른 설치 파일들로 인하여 pip 실행해서 설치 불가

python -m pip install https://download.pytorch.org/whl/cu100/torch-1.1.0-cp37-cp37m-win_amd64.whl

결과

설치가 되었으나, 경고문이 있다..

 

파이썬에서 'import torch'했을 때는 아직 에러가 발생하지 않았지만, 경고문은 향후에 항상 에러를 몰고다니니 나중에 해결해야 겠다

 

반응형