계속 windows에서만 작업하다가 ubuntu에서 작업할 일이 생겨서

 

부랴부랴 구글의 도움을 받아 세팅을 완료했다.

 

이전에도 ubuntu에서 작업했지만 좀 오래되서 다 까먹음..

 

서버를 제공받은터라 putty를 통해 세팅을 진행했다.

 

또한 cuda 10.1과 cuDNN 7.6.5로 version을 정한 이유는

 

google colab pro 및 pytorch를 사용중인데

 

거기서 사용하는 version이기 때문이다. (구글 형님 믿고 갑니다)

 

ubuntu는 설치되어있다고 가정하에 cuda 설치를 진행한다.

 

cuda 설치시 driver가 설치되기 때문에 따로 graphic driver를 설치하지 않아도 된다.

 

- 기존 driver 및 cuda가 설치되어 있을 시 제거

$sudo apt-get purge nvidia* && sudo apt-get autoremove && sudo apt-get autoclean && sudo rm -rf /usr/local/cuda*

 

- cuda 10.1 update 2 다운로드 및 설치

 

developer.nvidia.com/cuda-10.1-download-archive-update2?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=runfilelocal

 

CUDA Toolkit 10.1 update2 Archive

Select Target Platform Click on the green buttons that describe your target platform. Only supported platforms will be shown. Operating System Architecture Distribution Version Installer Type Do you want to cross-compile? Yes No Select Host Platform Click

developer.nvidia.com

위의 링크로 가면 Installation Instructions에 따라 다운로드 받고 설치할 수 있다.

 

- 설치가 잘 됐는지 version check

 

nvidia-smi or nvcc --version

 

- cuDNN 7.6.5 설치

nvidia 계정을 생성 및 로그인을 통해 cuDNN 7.6.5를 다운받자.

 

linux용으로 확장자가 solitairetheme8 라는 이름으로 되어있다.

 

아래 명령어로 압축을 해제하자.

$tar -xzvf cudnn-10.1-linux-x64-v7.6.5.32.solitairetheme8

그리고 아래의 명령어로 cudnn을 등록?하자.

$sudo cp cuda/include/cudnn.h /usr/local/cuda/include
$sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
$sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

- anaconda 설치

 

www.anaconda.com/products/individual

 

Anaconda | Individual Edition

Anaconda's open-source Individual Edition is the easiest way to perform Python/R data science and machine learning on a single machine.

www.anaconda.com

위의 링크에서 linux용으로 다운로드 받고 bash쉘로 실행시켜서 설치하자.

$bash ./Anaconda3-2020.07-Linux-x86_64.sh

 

- pytorch 설치

 

cuda 10.1용 pytorch를 설치하자.

$conda install pytorch torchvision torchaudio cudatoolkit=10.1 -c pytorch

 

- python을 실행해서 torch에서 cuda 설치가 잘 됐는지 확인하자.

import torch
torch.cuda.is_available()

설치에 이상이 없으면 True 값이 반환될 것이다.

+ Recent posts