본문 바로가기

카테고리 없음

Pytorch 관련 패키지와 torch_geometric 한번에 설치하기

 

pytorch 와 torch_geometric 버전을 함께 맞추어야 한다는 사실을 늦게 ㅇ..... 알게되었다 

저와 같은 경험을 하는 분들이 계실거같아서 정리를 하게되었습니다. 

 

https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html

 

Installation — pytorch_geometric documentation

PyG is available for Python 3.7 to Python 3.11. Note We do not recommend installation as a root user on your system Python. Please setup a virtual environment, e.g., via Anaconda or Miniconda, or create a Docker image.

pytorch-geometric.readthedocs.io

 

 

우선 저는 CUDA 11.8을 사용하고있고 PYTORCH는 2.0.1을 설치 했으나.. .

torch_geometric 에서 게속 오류가 나고 그래서 

PyG doc를 보니 torch와 버전을 맞추어야 한다는것을 알게되었다 ..

 

어차피 패키지는 아나콘다에서 관리하니까 새로운 가상환경에 재설치를 하게 되었다. 

 

pip3 install torch==2.0.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

우선 torch 버전을 2.0.0으로 하고 남어지는 알아서 ~pip가 버전을 맞추어준다 단 코드 마지막에 CUDA 버전을 확인하고 넣어줄것!

 

pip install torch_geometric
pip install torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.0.0+cu118.html

그 다음은 torch_geometric 설치하는 부분이다. 두번째 줄의 마지막에 torch 2.0.0 과 cu118 를 맞추면 된다! 

이 버전을 맞추지 않고 사용하면 오류가 발생합니다. . 

두번째 줄을 설치 안하고 torch_geometric 을 사용할 때 sparse 오류가 발생하니 함께 설치!! 

Sparse 오류 

import error in torch-scatter, torch-sparse and torch-geometric

 

import error in torch-scatter, 오류는 두번째 줄로 해결 가능

 

그리고 패키지가 중복되서 나타나는 오류를 

다음 코드를 넣어서 하면 오류가 해결 된다 라고 나올 것이다 하지만 이 방법은 패키지 중복을 허용하라 라는 의미로 

좋은 방법이 아니다라고 구글님이 알려주셨다. 아래 링크는 저 또한 발생했던 오류를 해결하는데 도움을 준 링크

아래 링크 안봐도 제가 알려드린 방법대로 하시면 문제 없을 겁니다  

https://stackoverflow.com/questions/20554074/sklearn-omp-error-15-initializing-libiomp5md-dll-but-found-mk2iomp5md-dll-a

 

sklearn OMP: Error #15 ("Initializing libiomp5md.dll, but found mk2iomp5md.dll already initialized.") when fitting models

I have recently uninstalled a nicely working copy of Enthought Canopy 32-bit and installed Canopy version 1.1.0 (64 bit). When I try to use sklearn to fit a model my kernel crashes, and I get the

stackoverflow.com

import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'

 

그래서! 아래의 패키지를 설치하면 ? 된다해서 설치 해보니 아무런 오류 없이 잘 동작하게 된다. 

conda install -c conda-forge nomkl

 

 

 

저는 CUDA 11.8에서 구동하였습니다 버전 확인하시고 사용하세요 

책임은 설치한 스스로에게 ... 있습니다! 

pip3 install torch==2.0.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118


pip install torch_geometric
pip install torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.0.0+cu118.html

conda install -c conda-forge nomkl

 

저의 생각의 흐름으로 정리한 내용입니다 

질문이 있다면 공개 댓글로 남겨주시면 답변하겠습니다. !!  

 

Baaaam