IT/ai

linux에서 anaconda 설치 후 pytorch 환경에서 jupyter notebook 실행

seyeonHello 2021. 2. 4. 10:16

pytorch는 pip나 conda로 설치 가능합니다. 이번 포스팅에서는 conda를 이용하여 pytorch를 설치해보겠습니다.

 

1. anaconda 다운로드 링크

https://www.anaconda.com/products/individual#download-section

 

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

anaconda installers

여기서 Linux 64-bit (x86) Installer를 설치하였습니다.

 

 

2.  설치 파일 실행

$ sh Anaconda3-2020.11-Linux-x86_64.sh

설치 진행 중 모든 메시지에 대해 yes 혹은 엔터를 입력해주세요. 설치 완료 후 reboot 명령어를 통해 컴퓨터를 재부팅 시킵니다.

 

 

3. conda 설치 확인

환경변수 설정 후, 설치된 conda의 version을 확인합니다.

$ export PATH="/home/user01/anaconda3/bin:$PATH"
$ conda --version

 

 

4. 가상환경 설정

python==3.7의 pytorch라는 이름의 가상환경을 생성 후,

$ conda create -n pytorch python=3.7

 

홈 디렉토리로 이동하여 아래의 명령어를 입력합니다.

$ source ~/anaconda3/etc/profile.d/conda.sh

 

그리고 가상환경을 활성화 시킵니다.

$ conda activate pytorch

정상적으로 실행되면 bash창에 (pytorch)를 확인할 수 있습니다.

 

5. CPU기반 pytorch 설치 

$ conda install pytorch torchvision -c soumith

 

+ 다른 라이브러리 설치

$ conda install jupyter pandas matplotlib

 

 

6. jupyter notebook 실행

$ jupyter notebook