학교/졸프

KcBERT 실습해보기(1)

daykim 2021. 4. 16. 20:50

개발환경 구축

1. 아나콘다 설치

- 아나콘다 사용시 데이터 과학 작업에 자주 사용하는 패키지를 간단하게 설치할 수 있음

https://www.anaconda.com/distribution/#windows 

 

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

 

2. VSCode에 연결하기

- VSCode에서 import torch에서 ModuleNotFoundError: No module named 'torch' 라는 메세지가 뜨는 경우

 

1. 아나콘다 프롬프트에서 python 가상환경 만들기
- conda create -n 가상환경 이름 python=3.8

- ptenv는 임의로 정한 이름

# 가상환경 실행
conda activate ptenv

# 가상환경 종료
conda deactivate ptenv

- 실행 코드를 통해 (base)가 (ptenv)로 바뀌면 성공

 

2. conda install pytorch

 

3. VSCode아래부분을 사진처럼 바꿔주면 된다.

- 'ImportError: numpy.core.multiarray failed to import'가 나오는 경우

  • numpy 버전이 낮아서 또는 아나콘다와 버전이 달라서 생기는 문제
  • pip install -U numpy
  • vscode와 아나콘다 프롬프트에서 둘 다 해줌

- 확인

 

- 실행 때 아래와 같은 오류 나올 때

conda : 'conda' 용어가 cmdlet, 함수, 스크립트 파일 또는 실행할 수 있는 프로그램 이름으로 인식되지 않습니다. 이름이 정확한지 확인하고 경로가 포함된 경우 경로가 올바른지 검증 한 다음 다시 시도하십시오.

-> 이는 터미널이 powershell로 되어있기 때문이라고 한다.

 

howtolivelikehuman.tistory.com/130

위의 링크를 보면 Ctrl+Shift+P이후 Terminal: Select Default Shell을 입력하라고 나오지만,

현재 내가 사용하는 VSCode에는 Terminal: Select Default Profile로 되어있다.

 

3. Pytorch 설치

https://pytorch.org/ 

 

PyTorch

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

pytorch.org

- 아나콘다 프롬프트 실행해 명령어 붙여넣기

- 참고 : databonanza.tistory.com/17

- 설치 확인

 

4. Transformer 설치

- 참고 : github.com/huggingface/transformers#installation

- 참고 :  huggingface.co/transformers/installation.html

- conda install -c huggingface transformers

OR

- pip install transformers[torch]

 

 

'학교 > 졸프' 카테고리의 다른 글

TF-IDF  (0) 2021.05.05
Faiss  (0) 2021.05.01
KcBERT 실습해보기(2)  (0) 2021.04.21
자연어처리 및 언어모델  (0) 2021.04.12
BERT  (0) 2021.04.11