Git Product home page Git Product logo

Using Compute Canada resources with VS Code for GPU programming

This guide will help you set up your Compute Canada environment with VS Code for GPU programming and job allocation.

Prerequisites

  • SSH Extension in VS Code
  • Jupyter Notebook extension in VS Code
  • An account on Compute Canada with access to GPU resources

Steps

1. Connect to Compute Canada via SSH in VS Code

  • Open VS Code.
  • Click on the green bottom-left button (Remote - SSH).
  • Enter your Compute Canada credentials ([email protected]).

2. Set up your virtual environment

  • Once connected, open a terminal in VS Code.
  • Create a new virtual environment (replace my_venv with your desired environment name): python -m venv my_venv
  • Activate the environment: source my_venv/bin/activate
  • Install necessary packages (like torch): pip install pytorch

3. Check for GPU availability

  • Run the following command: nvidia-smi.
    • If you get an error saying NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running., this means you are not on a GPU node.

4. Allocate GPU resources

  • Run the following command to allocate GPU resources: salloc --time=1:00:00 --gres=gpu:1 --cpus-per-task=1 --account=def-<YourComputeCanadaAccount> --mem=8G.
    • Replace <YourComputeCanadaAccount> with your Compute Canada account name.
    • Adjust time, GPU, CPU, and memory allocation as per your needs.

5. Run Jupyter Notebook server

  • Once you have allocated resources and are on a GPU node, run the following command to start a Jupyter notebook server: jupyter notebook --no-browser --ip=0.0.0.0 --port=8888.

6. Connect VS Code to the Jupyter server

  • In VS Code, open the Command Palette (F1 or Ctrl+Shift+P).
  • Enter Jupyter: Create New Blank Notebook.
  • Click on the "Select Kernel" button in the top-right of the notebook interface.
  • Click on the "Add kernel" button at the bottom of the kernel selection list.
  • You'll be asked for the URL of the Jupyter server. Enter the URL provided by the server when you started it.
  • The new kernel should now appear in the kernel list. Select it to use it for your notebook.

7. Test GPU in Jupyter notebook

  • In a new Jupyter notebook cell, run the following Python code to check if GPU is available:
import torch
torch.cuda.is_available()
  • If it returns True, it means GPU is available in your Jupyter notebook.

Sher Badshah's Projects

disk_quota_exceeded_errno_122 icon disk_quota_exceeded_errno_122

This guide aims to help users who have encountered the "disk quota exceeded" error on shared computing systems. Below, you'll find the error message, an explanation, and step-by-step instructions to resolve the issue.

easyedit icon easyedit

An Easy-to-use Framework to Edit Large Language Models.

robust_qa icon robust_qa

Low-Rank Adaptation of Large Language Models for Robust Question Answering

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.