파이썬
[Python] Colab(코랩)과 로컬 Pycharm 연동하기
필경이야
2021. 12. 8. 16:58
Colab(코랩)과 로컬 Pycharm 연동하기
- 코랩계정
- ngrok 계정
- pycharm Professional (학생은 1년 무료)
NGROK
- https://dashboard.ngrok.com/get-started/setup 접속하여 회원가입 후 토큰을 복사한다.
Colab
- 런타임 > 런타임유형 변경 > GPU로 변경
- GPU 설정 확인, Cuda 버전도 확인
!nvidia-smi
- 드라이브 마운트
from google.colab import drive
drive.mount('/content/drive')
- 토큰, 패스워드 설정
# https://dashboard.ngrok.com/get-started/setup
# 에서 생성한 토큰번호
NGROK_TOKEN = '토큰토큰'
PASSWORD = '패스패스'
- ssh 연결 설정
!pip install colab-ssh
from colab_ssh import launch_ssh
launch_ssh(NGROK_TOKEN,PASSWORD)
# professional 학생용 1년 무료
# www.jetbrains.com/ko-kr/community/education/#students
#Pycharm에서 안되면 여러번 해본다.
Warning: Due to some issues with ngrok on Google Colab, reported in the issue https://github.com/WassimBenzarti/colab-ssh/issues/45,
we highly recommend that update your code by following this documentation https://github.com/WassimBenzarti/colab-ssh#getting-started
Successfully running 2.tcp.ngrok.io:16193
[Optional] You can also connect with VSCode SSH Remote extension using this configuration:
Host google_colab_ssh
HostName 2.tcp.ngrok.io
User root
Port 16193
PyCharm
- File > Settings > Project > Python Interpreter > Add
- SSH Interpreter > 위에서 입력받은 HostName, User, Port 순서대로 입력 후 확인
- 연결이 완료되면 패스워드 입력
- Interpreter를 Python3로 변경해준다.
- Sync Folder를 원하는 Colab경로로 변경해준다..
이후 확인
- https://dashboard.ngrok.com/endpoints/status 에 접속하여 터널리스트(엔드포인트)를 확인한다.
- 로컬에 있는 Project가 Colab으로 잘 업로드 되는지 확인한다.
- 학습을 시켜본다
소감
로컬에서 학습 6시간 걸렸는데 코랩 GPU사용하니까 10분?정도 소요된 것 같다.. 어쩜 이래 차이가 많이나는지.. 좋아요!