Skip to content

Instantly share code, notes, and snippets.

View leofang's full-sized avatar

Leo Fang leofang

View GitHub Profile
@BvB93
BvB93 / func_to_protocol.py
Last active February 16, 2024 12:24
Convert all functions in the passed input file into runtime checkable `__call__`-based protocols
"""Convert all functions in the passed input file into runtime checkable `__call__`-based protocols.
Requires the `black` and `isort` linters.
"""
from __future__ import annotations
import sys
import ast
@repi
repi / crate-health.md
Last active February 22, 2024 01:17
Guidelines on evaluating health & quality of third-party crates at Embark

What to evaluate and consider before adding usage of new third-party crates.

These are not exact requirements but questions to investigate and discuss to help reason around the health, safety, maintainability, and more around crates.

This can also be read as an opinionated guide for crate authors of what our (Embark's) guidelines and recommendations are, though should not be taken too literally.

Legend: 🔒 Must have, ⭐️ Should have, 👍 Nice to have, ℹ️ Info

@hadim
hadim / cuda.sh
Last active December 24, 2020 21:37
Bash functions to manage your Cuda/cuDNN installations on Linux (tested only on Ubuntu).
#!/usr/bin/env bash
# Cuda and friends installation done right.
# Switch default Cuda version using symbolic link: cuda.switch 9.2
# Install Cuda: cuda.install.cuda 10.0
# Install cuDNN to CUDA_HOME: cuda.install.cudnn 7.5
# Install NCCL to CUDA_HOME: cuda.install.nccl 2.4
# Install Cuda, cuDNN and NCCL: cuda.install 10.0 7.5 2.4
# Author: Hadrien Mary <hadrien.mary@gmail.com>
@ASvyatkovskiy
ASvyatkovskiy / gpuarray_allreduce_test.py
Created August 29, 2017 03:14
Test CUDA-aware mpi4py with pycuda gpuarrays
#!/usr/bin/env python
from mpi4py import MPI
import numpy as np
import time
import pycuda.autoinit
from pycuda import gpuarray
comm = MPI.COMM_WORLD
comm_rank = comm.Get_rank()
@joyrexus
joyrexus / README.md
Last active February 24, 2024 15:16
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@nepsilon
nepsilon / python-how-to-print-the-full-traceback-without-exiting-the-program.md
Created January 3, 2017 06:24
Python: How to print the full traceback without exiting the program? — First published in fullweb.io issue #81

Python: How to print the full traceback without exiting the program?

The exception handling block except Exception as ex: print(ex) will only print the exception message and not its traceback.

That’s good to know, but we need more info than this to debug properly. Namely the line that raised the exception, together with its stack trace.

The traceback module, part of the stdlib, will help us with this:

@lebedov
lebedov / mpi4py_pycuda_demo.py
Last active December 2, 2022 04:23
Demo of how to pass GPU memory managed by pycuda to mpi4py.
#!/usr/bin/env python
"""
Demo of how to pass GPU memory managed by pycuda to mpi4py.
Notes
-----
This code can be used to perform peer-to-peer communication of data via
NVIDIA's GPUDirect technology if mpi4py has been built against a
CUDA-enabled MPI implementation.
@lebedov
lebedov / multi_pycuda_ipc_demo.py
Created September 2, 2013 00:10
Allocate a GPUArray in one process and access it in another process using IPC handles.
#!/usr/bin/env python
"""
Allocate a GPUArray in one process and access it in another process using IPC
handles.
"""
import multiprocessing as mp
import numpy as np
import zmq
@lebedov
lebedov / ipc_demo.py
Created March 17, 2013 01:48
Demonstrate how to pass IPC handles to GPU data between processes in Python
#!/usr/bin/env python
"""
Demonstrate how to pass IPC handles to GPU data between processes in Python.
"""
import ctypes
import numpy as np
import multiprocessing as mp
import zmq
@return1
return1 / trim_enabler.txt
Last active August 25, 2023 02:59
TRIM Enabler for OS X Yosemite 10.10.3
#
# UPDATE for 10.10.4+: please consider this patch obsolete, as apple provides a tool called "trimforce" to enable trim support for 3rd party SSDs
# just run "sudo trimforce enable" to activate the trim support from now on!
#
# Original version by Grant Parnell is offline (http://digitaldj.net/2011/07/21/trim-enabler-for-lion/)
# Update July 2014: no longer offline, see https://digitaldj.net/blog/2011/11/17/trim-enabler-for-os-x-lion-mountain-lion-mavericks/
#
# Looks for "Apple" string in HD kext, changes it to a wildcard match for anything
#
# Alternative to http://www.groths.org/trim-enabler-3-0-released/