Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pcaversaccio/connection-vscode-to-google-colab-gpus
A step-by-step guide to connecting the local Visual Studio Code to Google Colab's GPU runtime.
https://github.com/pcaversaccio/connection-vscode-to-google-colab-gpus
deeplearning googlecolab gpu vscode
Last synced: 15 days ago
JSON representation
A step-by-step guide to connecting the local Visual Studio Code to Google Colab's GPU runtime.
- Host: GitHub
- URL: https://github.com/pcaversaccio/connection-vscode-to-google-colab-gpus
- Owner: pcaversaccio
- License: wtfpl
- Created: 2021-03-05T17:36:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-03-05T20:05:10.000Z (over 3 years ago)
- Last Synced: 2024-10-13T23:07:50.514Z (about 1 month ago)
- Topics: deeplearning, googlecolab, gpu, vscode
- Homepage:
- Size: 5.86 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# A Step-by-Step Guide to Connecting the Local Visual Studio Code to Google Colab's GPU Runtime
## Requirements
- A Google account of course (yeah I know Google sucks).
- Visual Studio Code installed on your operating system.## Steps
### Step 1
First, you need to have a Cloudfare binary file. You can download it for your corresponding operating system from [here](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation) and follow all the instructions accordingly.### Step 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, if it is the `C:` drive, you will have to write the path as `C:\\cloudflared.exe`.
> Note the double backslash `C:\\cloudflared.exe`, one backslash would not do it!### Step 3
Next, open Visual Studio Code and install the `Remote-SSH` extension. After installing, press `Ctrl + Shift + P` and search for `Remote Configuration File`. Then, hit enter and paste the following lines in the configuration file:
```
Host *.trycloudflare.com
HostName %h
User root
Port 22
ProxyCommand access ssh --hostname %h
```
> Note that you need to put the absolute path to the binary file which we copied in Step 2.### Step 4
After preparing your configuration file, open [Google Colab](https://colab.research.google.com/) and launch a new notebook and connect to a GPU runtime if you need one. Also, mount your Google drive if you want to access your drive files.
```
from google.colab import drive
drive.mount('/content/drive')
```
Finally, paste the following code snippet in a cell and enter a password of your choice (generally I prefer: "Gofuckyourself"):
```
# Install colab_ssh on google colab
!pip install colab_ssh --upgradefrom colab_ssh import launch_ssh_cloudflared, init_git_cloudflared
launch_ssh_cloudflared(password="")# Optional: if you want to clone a github repository
init_git_cloudflared(githubRepositoryUrl)# To avoid the timeout in Google Colab due to inactivity
while True: pass
```### Step 5
Copy the appearing ``VSCode Remote SSH`` hostname. Go back to your Visual Studio Code and again hit `Ctrl + Shift + P` and search for `Remote:Connect to Host`.Paste the Visual Studio Code's hostname and press enter. Select Linux as the platform and hit enter. It will ask for the password you have set previously and voilà you are now connected to Google Colab with GPU access all bundled in your Visual Studio Code!
You can check if you have GPU access by opening a new terminal and hitting the `nvidia-smi` command.
### Step 6
You can open any folder in your Google drive. Just copy the path of the folder and paste it into Visual Studio Code. Keep the Google Colab tab open in the browser.### Note
It may take some time for connecting to the Google Colab via SSH. Also, you must run python files by using `python3 ` in the terminal to ensure your files run in `Python-3.x`. If you use only `python ` the Google Colab would use `Python-2` at the backend.#### If you are on Windows:
After you are done with your work in the workspace, always open a PowerShell window at the `cloudflared`'s binary file location and execute the following command:
```
.\cloudflared.exe update
```
> This has to be done because instances of `cloudflared` do not automatically update on Windows which may cause problem for new instances of `cloudflared`.## License
[Do What The F*ck You Want To Public License](https://choosealicense.com/licenses/wtfpl/)