+ All Categories
Home > Documents > Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq...

Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq...

Date post: 25-May-2020
Category:
Upload: others
View: 16 times
Download: 0 times
Share this document with a friend
25
2018.04.05 최건호 Google Colaboratory 사용법
Transcript
Page 1: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

2018.04.05

최건호

GoogleColaboratory사용법

Page 2: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

간단히 말하면 Google에서 제공하는 Jupyter Notebook입니다.

Page 3: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

GPU가 있다고 하길래한번 확인해 보았습니다.

Page 4: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

무려 테슬라 K80

GPU가 있다고 하길래한번 확인해 보았습니다.

Page 5: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

계속 쓸 수 있는건가??

안타깝지만 한번에 연속 12시간만 사용할 수 있다고 합니다.하지만 하나의 인스턴스에 연속 12시간이기 때문에 끝나고다른 곳에서 실행하면 된다고 합니다.

Page 6: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

구글에 가서 드라이브로 들어갑니다.

Page 7: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

새로 폴더를 만들어주면 깔끔합니다.

Page 8: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

우클릭 후, 더보기 - 연결할 앱 더 보기로 들어갑니다.

Page 9: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

Colab를 구글 드라이브에 연결해줍니다.

Page 10: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

Colab를 하나 생성합니다.

Page 11: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

사용할 준비 끝

Page 12: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

GPU를 사용하기 위해서는 수정 – 노트 설정 에서

Page 13: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

하드웨어 가속기에서 GPU를 선택해줍니다.

Page 14: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

테스트 해보려 import torch를 했지만 깔려 있지 않네요

Page 15: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

Install Torch를 누르면 명령어가 자동으로 입력되고 실행하면 설치됩니다.

Page 16: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

Tensorflow는 미리 설치되어 있었고 둘 다 잘 작동합니다.

Page 17: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

https://stackoverflow.com/questions/48750199/google-colaboratory-misleading-information-about-its-gpu-only-5-ram-available

CPU와 GPU 스펙을 체크해보면 위와 같이 나옵니다.

Page 18: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

https://colab.research.google.com/notebooks/io.ipynb

로컬에 있는 파일을 업로드하거나 다운 받는것도 가능합니다.

Page 19: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab. 구글 드라이브 마운트

디렉토리를 이동할때는 cd 는 안먹히고 os.chdir()로 이동합니다.

Page 20: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

구글 드라이브 마운트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

Page 21: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

구글 드라이브 마운트

/home 에 drive 라는 폴더를 만들고 여기에 Google Drive Mount

아까 만든 Colab 폴더에 git clone repo

GoogleColab.

Page 22: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

구글 드라이브 마운트

해당 폴더에 clone 되었음을 확인할 수 있습니다.

GoogleColab.

Page 23: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

파일을 열어보면 Google Colab.로 열리는 것을 확인할 수 있음

Page 24: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

GoogleColab.

GPU 모드로 바꿔서 실행해보면 잘 돌아가는것을 확인할 수 있습니다.

Page 25: Google Colab 사용법...Google Colab. 구글 드라이브 마운트!apt-get install -y -qq software-properties -common python-software-properties module-init-tools

감사합니다J


Recommended