GCP에서 TPU 사용하기

hunsii·2023년 4월 20일
0

1. TPU 빌리기

출처

2.TPU VM 생성

GCP에서 수동으로 만들어도 되지만 아래와 같은 명령어로도 만들 수 있습니다.
해당 명령어는 gcloud를 설치해야 사용 가능합니다.

이 명령어는 europe-west4-a region에서 instance-name이라는 VM 인스턴스 이름을 가진 V3 TPU를 빌리는 과정입니다.

gcloud alpha compute tpus tpu-vm create instance-name --zone europe-west4-a --accelerator-type v3-8 --version tpu-vm-base

V4

gcloud compute tpus tpu-vm create tpu-name \
    --zone=us-central2-b \
    --accelerator-type=v4-64 \
    --version=tpu-ubuntu2204-base 

3. Cloud TPU VM에 연결

다음과 같은 명령어로 TPU VM에 연결할 수 있습니다.

gcloud compute tpus tpu-vm ssh tpu-name --zone us-central2-b

출처

4. 업데이트 및 필요한 것들 설치

4-1. 일단 업데이트 및 screen 설치

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install screen

4-2. 아나콘다 설치

아나콘다 홈페이지 다운로드 링크

wget https://repo.anaconda.com/archive/Anaconda3-2023.03-Linux-x86_64.sh
sh Anaconda3-2023.03-Linux-x86_64.sh

4-3. 필요한 파이썬 패키지들 설치

pip install --upgrade pip
conda install -c anaconda jupyter
conda install -c conda-forge ipykernel
conda install -c conda-forge gdown

pip install jax[tpu] -f https://storage.googleapis.com/jax-releases/libtpu_releases.html

jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --NotebookApp.token=''

# 외부 ip 보는 방법
curl ident.me

4-4. (선택) 주피터 커널 연결

conda create -n env_name python=3.8
conda activate env_name
python -m ipykernel install --user --name=env_name

출처

애러시

opencv설치시

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

sudo apt install libgl1-mesa-glx

같은 애러 발생시
https://stackoverflow.com/questions/55313610/importerror-libgl-so-1-cannot-open-shared-object-file-no-such-file-or-directo

import albumentations

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

scipy 설치

sudo apt-get update
sudo apt-get upgrade
pip install --upgrade scipy # conda install scipy
profile
딥러닝을 공부하는 학생입니다

0개의 댓글