Skip to content

Instantly share code, notes, and snippets.

View sfoucher's full-sized avatar

Samuel Foucher sfoucher

  • University of Sherbrooke
  • Sherbrooke
View GitHub Profile
@sweenzor
sweenzor / shapely-demo.ipynb
Last active January 19, 2022 14:45
Shapely ipython notebook example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mrtns
mrtns / gist:78d15e3263b2f6a231fe
Last active May 19, 2024 06:53
Upgrade Chrome from Command Line on Ubuntu
# Install
# via http://askubuntu.com/questions/510056/how-to-install-google-chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
# Update
@tonyfast
tonyfast / yamlDemo.ipynb
Last active April 13, 2022 15:16
Demonstration of YAML parsers in the Jupyter Notebook http://nbviewer.ipython.org/gist/tonyfast/e4bf0b6d77225faf1b04
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gbishop
gbishop / Args.ipynb
Last active July 18, 2022 11:43
Allow arguments to be passed to notebooks via URL or command line.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thomwolf
thomwolf / gradient_accumulation.py
Last active January 16, 2024 02:38
PyTorch gradient accumulation training loop
model.zero_grad() # Reset gradients tensors
for i, (inputs, labels) in enumerate(training_set):
predictions = model(inputs) # Forward pass
loss = loss_function(predictions, labels) # Compute loss function
loss = loss / accumulation_steps # Normalize our loss (if averaged)
loss.backward() # Backward pass
if (i+1) % accumulation_steps == 0: # Wait for several backward steps
optimizer.step() # Now we can do an optimizer step
model.zero_grad() # Reset gradients tensors
if (i+1) % evaluation_steps == 0: # Evaluate the model when we...
@dustinandrews
dustinandrews / bsp.py
Created October 24, 2019 21:26
Binary Space Partitioning didactic example in Python
# -*- coding: utf-8 -*-
"""
Pure Python 3.6 example of doing binary space partioning for rectangles
Note the example is meant to be illustrative rather than performant, idiomatic or compact
Copyright 2019 Dustin Andrews
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@mrm8488
mrm8488 / ngrok_tensorboard_colab.md
Last active September 19, 2022 09:35
Setup ngrok and run TensorBoard on Colab
@martinsotir
martinsotir / google_ai_notebooks_tips.md
Last active July 8, 2023 13:29
Google AI notebook tips

Google AI Platform Notebook tips

AI Notebooks vs Colab

Google Colab: https://colab.research.google.com/

  • Free compute! and interesting, fixed cost, 10$/month Google Colab Pro version.
  • Notebooks are very easy to share, with ability to control permissions (integration in google drive/doc ecosystem).
  • Instant availability. No requirement other than a regular google account.
  • Idle time limit : 1h in free version.
@ckandoth
ckandoth / single_machine_slurm_on_ubuntu.md
Last active May 19, 2024 07:49
Install Slurm 19.05 on a standalone machine running Ubuntu 20.04

Use apt to install the necessary packages:

sudo apt install -y slurm-wlm slurm-wlm-doc

Load file:///usr/share/doc/slurm-wlm/html/configurator.html in a browser (or file://wsl%24/Ubuntu/usr/share/doc/slurm-wlm/html/configurator.html on WSL2), and:

  1. Set your machine's hostname in SlurmctldHost and NodeName.
  2. Set CPUs as appropriate, and optionally Sockets, CoresPerSocket, and ThreadsPerCore. Use command lscpu to find what you have.
  3. Set RealMemory to the number of megabytes you want to allocate to Slurm jobs,
  4. Set StateSaveLocation to /var/spool/slurm-llnl.
  5. Set ProctrackType to linuxproc because processes are less likely to escape Slurm control on a single machine config.
@ameya98
ameya98 / install_PyG.py
Last active June 2, 2024 11:38
Google Colab: PyTorch Geometric Installation
# Add this in a Google Colab cell to install the correct version of Pytorch Geometric.
import torch
def format_pytorch_version(version):
return version.split('+')[0]
TORCH_version = torch.__version__
TORCH = format_pytorch_version(TORCH_version)
def format_cuda_version(version):