VSCode에서 Google Colab GPU Runtime 접속하기

2021. 3. 1. 23:42꿀팁 분석 환경 설정

728x90

아래 블로그를 참고해서 하나씩 직접 진행중...

Steps:

  1. First, you need to have a cloudfare binary file. You can download it for your corresponding operating system from here. Follow all the instructions given here to install it.
  2. Once cloudflared is installed, you will have a binary(.exe) file after extracting the package. Copy the exact path to the binary file. For example, in my case it is in C drive, so I will write the path as C:\\cloudflared.exe.

난 윈도우 10이니 64를 다운로드했습니다.

 

./아래 설명서가 있어서 참고해서 진행합니다.

간단히 말해서 다운로드해서 집을 풀고, powershell에서 exe파일 실행시키는 것입니다. 

 

Once cloudflared is installed:

  1. Navigate to the Downloads folder.
  2. Right-click on the ZIP folder and select Extract All to extract the executable.
  3. Next, open PowerShell.
  4. Navigate to the same Downloads folder.
  5. Run the cloudflared.exe executable as an administrator to confirm the installation, replacing the path in the example below with the specifics of your directory:

 

예시

 

vs code 들어가서 설정하기

1.Remote-SSH extension 설치하기

2. Remote Configuration File 수정하기(ctrl +shift + p 누르고 Remote Configuration file 누르기)

 

아래와 같이 하나 더 추가하기

Host *.trycloudflare.com
 HostName %h
 User root
 Port 22
 ProxyCommand <PUT_THE_ABSOLUTE_CLOUDFLARE_PATH_HERE> access ssh --hostname %h

필자는 아래와 같이 만듬

Host *.trycloudflare.com
 HostName %h
 User root
 Port 22
 ProxyCommand D:/cloudflare/cloudflared.exe access ssh --hostname %h

예시

google colab 들어가서 작업하기

1. (optional) 구글 드라이브 연결 시키기 

2. vs code 연결하기 

 

from google.colab import drive
drive.mount('/content/gdrive')
# 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="test")
# Optional: if you want to clone a github repository
#init_git_cloudflared(githubRepositoryUrl)

vscode remote SSH 복사하기

vscode 들어가서 ssh 통신해보기

1. Ctrl + Shift + P (Remote SSH : Connect .. SSH) 누르기

2. 복사한 것 붙여 넣기

3. Linux 선택

4. Continue

5. password(colab에서 설정한 것) 치기

6. terminal 에서 nvidia-smi 해보기

 

(cpu, tpu는 nvidia-smi 할 때 아무것도 안나옴)

 

local vscode로 google drive에 접속해서 코딩할 수 있어서 참 편리할 것 같다는 생각이 든다.

디버깅 툴도 사용할 수 있고, 여러가지로 장점이 많아 보인다.

물론 매번 extension을 설치해야할 것 같기도 해서 불편하지만... 쓸 수 있는 것에 만족하면 될 것 같다.

 

참고

medium.com/swlh/connecting-local-vscode-to-google-colabs-gpu-runtime-bceda3d6cf64

728x90