VSCode에 Colab GPU 연동하는 법

yoonene·2022년 7월 20일

01. Cloudfare 바이너리 파일 설치

https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup

Mac은 brew로 다운 가능하다.
brew install cloudflare/cloudflare/cloudflared

VSCode 실행

  1. Remote-SSH Extension 설치
  2. command + shift + P 로 command palette를 열기
  3. Remote-SSH : Open configuration file을 실행
  4. /Users/<user name>/.ssh/config 수정(기존파일에 추가하는 방식)
	Host *.trycloudflare.com
    	HostName %h
    	User root
    	Port 22
    	ProxyCommand exec <cloudflared 경로> access ssh --hostname %h

Colab 실행

Google Colab의 새 노트북을 실행한다.(GPU 런타임 설정)
1. 아래 코드를 실행한다.

from google.colab import drive
# mount google drive 
drive.mount('/content/drive')
# Install colab_ssh on google colab
!pip install colab_ssh --upgrade
	
from colab_ssh import launch_ssh_cloudflared, init_git_cloudflared
launch_ssh_cloudflared(password="<YOUR_PASSWORD>")
  1. 코드를 실행하면 밑에 나오는 VSCode Remote SSH 복사

VSCode로 다시 돌아오기

  1. VSCode에서 command palette(command + shift + P)를 실행하고 Remote-SSH: Connect to host 선택
  2. 3-2에서 복사한 Remote SSH 붙여넣기

(여기까지 제대로 됐다면 새로운 vscode 창이 뜨고 비밀번호 입력칸이 뜬다.)

  1. 설정했던 비밀번호 입력
  2. open Folder를 눌러 작업할 구글드라이브 경로로 이동 (/content/drive/MyDrive/<원하는 경로>)
profile
NLP Researcher / Information Retrieval / Search

0개의 댓글