2018.04.05
최건호
GoogleColaboratory사용법
GoogleColab.
간단히 말하면 Google에서 제공하는 Jupyter Notebook입니다.
GoogleColab.
GPU가 있다고 하길래한번 확인해 보았습니다.
GoogleColab.
무려 테슬라 K80
GPU가 있다고 하길래한번 확인해 보았습니다.
GoogleColab.
계속 쓸 수 있는건가??
안타깝지만 한번에 연속 12시간만 사용할 수 있다고 합니다.하지만 하나의 인스턴스에 연속 12시간이기 때문에 끝나고다른 곳에서 실행하면 된다고 합니다.
GoogleColab.
구글에 가서 드라이브로 들어갑니다.
GoogleColab.
새로 폴더를 만들어주면 깔끔합니다.
GoogleColab.
우클릭 후, 더보기 - 연결할 앱 더 보기로 들어갑니다.
GoogleColab.
Colab를 구글 드라이브에 연결해줍니다.
GoogleColab.
Colab를 하나 생성합니다.
GoogleColab.
사용할 준비 끝
GoogleColab.
GPU를 사용하기 위해서는 수정 – 노트 설정 에서
GoogleColab.
하드웨어 가속기에서 GPU를 선택해줍니다.
GoogleColab.
테스트 해보려 import torch를 했지만 깔려 있지 않네요
GoogleColab.
Install Torch를 누르면 명령어가 자동으로 입력되고 실행하면 설치됩니다.
GoogleColab.
Tensorflow는 미리 설치되어 있었고 둘 다 잘 작동합니다.
GoogleColab.
https://stackoverflow.com/questions/48750199/google-colaboratory-misleading-information-about-its-gpu-only-5-ram-available
CPU와 GPU 스펙을 체크해보면 위와 같이 나옵니다.
GoogleColab.
https://colab.research.google.com/notebooks/io.ipynb
로컬에 있는 파일을 업로드하거나 다운 받는것도 가능합니다.
GoogleColab. 구글 드라이브 마운트
디렉토리를 이동할때는 cd 는 안먹히고 os.chdir()로 이동합니다.
구글 드라이브 마운트GoogleColab.
!apt-get install -y -qq software-properties-common python-software-properties module-init-tools!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null!apt-get update -qq 2>&1 > /dev/null!apt-get -y install -qq google-drive-ocamlfuse fuse
from google.colab import authauth.authenticate_user()
from oauth2client.client import GoogleCredentialscreds = GoogleCredentials.get_application_default()
import getpass!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URLvcode = getpass.getpass()!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}
https://medium.com/deep-learning-turkey/google-colab-free-gpu-tutorial-e113627b9f5d
구글 드라이브 마운트
/home 에 drive 라는 폴더를 만들고 여기에 Google Drive Mount
아까 만든 Colab 폴더에 git clone repo
GoogleColab.
구글 드라이브 마운트
해당 폴더에 clone 되었음을 확인할 수 있습니다.
GoogleColab.
GoogleColab.
파일을 열어보면 Google Colab.로 열리는 것을 확인할 수 있음
GoogleColab.
GPU 모드로 바꿔서 실행해보면 잘 돌아가는것을 확인할 수 있습니다.
감사합니다J