본문 바로가기
데이터분석 및 데이터엔지니어/파이썬

파이썬 KoBERT 패키지 설치 및 onnxruntime 설치오류

by na.__.na 2023. 11. 23.

ERROR: Could not find a version that satisfies the requirement onnxruntime<=1.8.0,==1.8.0 (from versions: 1.12.0, 1.12.1, 1.13.1, 1.14.0, 1.14.1, 1.15.0, 1.15.1, 1.16.0, 1.16.1, 1.16.2, 1.16.3)
ERROR: No matching distribution found for onnxruntime<=1.8.0,==1.8.0

 

KoBERT 모델을 사용하고자 사용되는 패키지를 모두 설치하려고 했는데

해당 오류가 발생했다. 

 

알고보니 파이썬 3.10은 안되고 파이썬 3.7에서 3.9 사이로 해야한다해서 가상환경을 새로 만들기로 결정 

특정 버전을 설치해줘야하니 버전 꼬일 우려가 있어 프로젝트마다 가상환경 만들어서 하는게 제일 깔끔하고 편하다 

 

터미널 환경 

 

> conda deactivate

일단 현재 환경 나가기 

 

> conda create -n kobert python=3.9

가상환경이름 kobert 생성. 파이썬 3.9로 생성 

 

> conda activate kobert

가상환경 입장 

 

> pip install -r requirements.txt

 

설치가 잘되는 듯 했지만 

 

ERROR: Cannot install -r requirements.txt (line 2), -r requirements.txt (line 3) and -r requirements.txt (line 4) because these package versions have conflicting dependencies.

The conflict is caused by:
    onnxruntime 1.8.0 depends on numpy>=1.16.6
    gluonnlp 0.6.0 depends on numpy
    mxnet 1.4.0.post0 depends on numpy<1.15.0 and >=1.8.2
    onnxruntime 1.8.0 depends on numpy>=1.16.6
    gluonnlp 0.6.0 depends on numpy
    mxnet 1.4.0 depends on numpy<1.15.0 and >=1.8.2

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

 

이런 오류가 발생

발생원인으로는 numpy 버전이 문제가 됨 

자동으로 numpy-1.16.6가 설치되었는데 1.16.2 이상이 되야하므로 numpy 버전을 1.8.2로 변경하려했으나

뭔가 계속 오류 뜨고 안되서 

가장 최신 버전인 1.26으로 설치완료 

 

그리고 다시 

 

> pip install -r requirements.txt

 

했으나

또 똑같은 오류 발생 

그래서 numpy 버전을 1.16.2로 변경. 근데도 오류 발생 

 

파이썬 버전 문제인가 싶어 파이썬 3.7로 다운그레이드. 그래도 같은 오류 발생 

transformers 최신버전은 파이썬 3.8 이상을 요구해서 다시 3.9로 업그레이드 ... 

 

최종 다운 받은 패키지 버전 정리 

호환되는거 찾는라 몇시간을 썼다 ... ㅠㅠ 

 

Python 3.9.18
boto3==1.15.18
gluonnlp==0.6.0
mxnet==1.7.0.post2
onnxruntime==1.8.0
sentencepiece==0.1.96
torch==1.7.1
transformers==4.8.1
numpy==1.16.6

 

(수정)

갑자기 또 안된다. 

numpy > 1.17 사용해야한단다 하 정말 짜증 

다시 도전 

 

최종

다른 블로그를 참고하여 파이썬 3.7과 transformers==3.0.2을 사용해줘야한다해서 그걸 먼저 다운로드 해주었다. 

근데 깃허브에는 transformers >= 4.8.1, <=4.8.1 이렇게 써있었는데

그래서 4.8.1만 써야한다는 뜻으로 알아들었는데 그냥 다 된다는 뜻이었나보다 

 

바로 해결되어 허무 ... 

 

진짜 최종 

다시 안되서 transformers==4.12.0 으로 바꿔주었더니 끝 !

 

최종 패키지 정보

boto3==1.15.18
gluonnlp==0.10.0
mxnet==1.7.0.post2
onnxruntime==1.8.0
sentencepiece==0.1.96
torch==1.10.1
transformers==4.12.0
numpy==1.21

 

예시코드 잘 되었다

근데 로컬환경에 GPU가 없어서 정말 느리다 ...