VSCode와 Colab 연동하기

IBLOG·2023년 7월 31일
3

Colab

목록 보기
1/2
post-thumbnail

VSCode에서 Colab의 GPU를 사용하기 위해 연동을 시켜보자.

1. Cloudfare 바이너리 파일 설치

brew install cloudflare/cloudflare/cloudflared

2. 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
        # ProxyCommand exec <cloudflared 경로> access ssh --hostname %h
        

3. Colab 실행

  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의 command를 복사한다.

4. VSCode와 Colab 연동하기

  1. VSCode에서 command palette(command + shift + P)를 실행하고 Remote-SSH: Connect to host 선택
  2. VSCode Remote SSH의 command를 Remote SSH에 붙여넣기
  3. 설정했던 비밀번호 입력
  4. open Folder를 눌러 작업할 구글드라이브 경로로 이동 (/content/drive/MyDrive/<원하는 경로>)

위의 작업을 다 마치면 VSCode에서 Colab을 사용할 수 있다.

profile
✢ 천천히 하나씩 기록해보자!

3개의 댓글

comment-user-thumbnail
2023년 7월 31일

잘 봤습니다. 좋은 글 감사합니다.

1개의 답글
comment-user-thumbnail
2024년 5월 16일

안녕하세요! 글 잘봤습니다
다름이 아니라 요렇게 연결 해두고 코랩 런타임이 끊기면 Cloudflared 코드 다시 실행해서 연결해야하고
익스텐션들이 다 날아가서요.. 요거 방지 방법이 있을까요? 도움 좀 부탁드립니다!

답글 달기