5. 파이썬
[Telaviv] 코랩(colab) 사용서
패스트코드블로그
2020. 5. 29. 22:33
from google.colab import auth
auth.authenticate_user()
from google.colab import drive
drive.mount('/content/gdrive')
root_dir = "/content/gdrive/My Drive/"
import pandas as pd
df = pd.read_csv(root_dir+'example_air_passengers.csv')
1
2
3
|
# Colab 서버 스펙 확인
from tensorflow.python.client import device_lib
device_lib.list_local_devices()
|
cs |
1
2
|
import platform
platform.platform()
|
cs |
'Linux-4.19.104+-x86_64-with-Ubuntu-18.04-bionic'
1
|
!cat /etc/issue.net
|
cs |
Ubuntu 18.04.3 LTS
1
|
!cat /proc/meminfo
|
cs |
1
|
!cat /proc/cpuinfo
|
cs |
1
|
!df -h
|
cs |
1
|
!nvidia-smi
|
cs |
1
|
!python --version
|
cs |
Python 3.6.9
1
|
!ls
|
cs |
sample_data
1
2
|
from tensorflow.python.client import device_lib
device_lib.list_local_devices()
|
cs |
1
2
3
|
# 파일 처리
%%writefile test.py
print('hello world!')
|
cs |
Overwriting test.py
1
2
|
# test.py 실행시키기
%run test.py
|
cs |
hello world!
1
2
3
|
from google.colab import files
# 브라우저에 다운로드 됨을 확인할 수 있다.
files.download('test.py')
|
cs |
1
2
3
4
|
# [Cancel upload] 버튼을 클릭하여 잠시 멈춘 후 파일선택 버튼을 클릭하면
# PC 내 파일을 선택할 수 있는 다이얼로그 창이 뜬다.
# 리턴값을 받는 변수인 myupload라는 이름의 디렉토리가 생성된다.
myupload = files.upload()
|
cs |
1
2
3
4
|
# 구글드라이브 연동
import os
print(os.getcwd())
!ls
|
cs |
/content
sample_data test.py
1
2
3
4
|
# 실행시 등장하는 URL을 클릭하여 허용해주면 인증KEY가 나타난다.
# 복사하여 URL아래 빈칸에 붙여넣으면 마운트에 성공하게된다.
from google.colab import drive
drive.mount('./MyDrive')
|
cs |
1
2
|
# 마운트된 내 드라이브를 확인해보자
!ls
|
cs |
MyDrive sample_data test.py
1
2
3
4
5
|
from google.colab import auth
auth.authenticate_user()
from google.colab import drive
drive.mount('/content/gdrive')
|
cs |
1
|
%pwd /content/gdrive/
|
cs |
'/content/gdrive/My Drive'
1
2
3
4
|
root_dir = "/content/gdrive/My Drive/"
import pandas as pd
df = pd.read_csv(root_dir+'example_air_passengers.csv')
df
|
cs |
https://zzsza.github.io/data/2018/08/30/google-colab/
Kaggle 연동하기
Google Colab 사용하기
Google의 Colab 사용법에 대해 정리한 글입니다 이 글은 계속 업데이트 될 예정입니다! 목차 UI 상단 설정 구글 드라이브와 Colab 연동 구글 드라이브와 로컬 연동 Tensorflow 2.0 설치하기 PyTorch 사용하기
zzsza.github.io