Skip to content

Instantly share code, notes, and snippets.

View tenpercent's full-sized avatar

Max Podkorytov tenpercent

  • San Francisco Bay Area
  • 16:37 (UTC -07:00)
View GitHub Profile
@tenpercent
tenpercent / configuration.nix
Created May 13, 2023 00:09
Dell 7540 Nixos config
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
let
nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" ''
export __NV_PRIME_RENDER_OFFLOAD=1
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
name: ait
channels:
- pytorch
- nvidia
- conda-forge
- defaults
dependencies:
- _libgcc_mutex=0.1=conda_forge
- _openmp_mutex=4.5=2_gnu
- binutils_impl_linux-64=2.38=h2a08ee3_1
@tenpercent
tenpercent / env.json
Last active December 17, 2019 00:07
Conda env: intel python plus some extras
{
"channels": [
"intel",
"defaults"
],
"dependencies": [
"_libgcc_mutex=0.1=main",
"_pytorch_select=0.2=gpu_0",
"absl-py=0.8.1=py36_0",
"asn1crypto=0.24.0=py36_3",
@tenpercent
tenpercent / pytorch-tpu-colab-setup.sh
Created December 9, 2019 19:50
Replace pytorch version provided by google colab with the one supporting TPU
TORCH_VER="20191208"
pip uninstall -y torch torchvision
rm -r wheels
mkdir -p wheels
for f in {torch,torch_xla,torchvision}; do
whl="${f}-nightly+${TORCH_VER}-cp36-cp36m-linux_x86_64.whl";
gsutil cp "gs://tpu-pytorch/wheels/${whl}" wheels/;
pip install "wheels/${whl}";
done
apt-get install -y libomp5
@tenpercent
tenpercent / uptr_pretty_printer.py
Last active November 17, 2015 17:28
pretty-printer for std::unique_ptr enabled for recursive printing
class MUniquePointerPrinter:
""" Print a unique_ptr with pointed-to-value
credits: https://gcc.gnu.org/ml/libstdc++/2013-04/msg00098.html
"""
def __init__ (self, typename, val):
self.val = val
def to_string (self):
v = self.val['_M_t']['_M_head_impl']
#include <iostream>
template<typename TNum>
constexpr TNum min2 (TNum first, TNum second)
{
return (first < second) ? first : second;
}
template<typename TNum, typename... Args>
constexpr TNum
@tenpercent
tenpercent / get_parallelogram_area.f
Created April 8, 2014 07:56
get parallelogram area
function get_parallelogram_area(vertice_a, vertice_b, vertice_c)
implicit none
real*8, dimension(1 : 3) :: vertice_a, vertice_b, vertice_c
real*8, dimension (1 : 3) :: vector_ab, vector_ac
real*8, dimension(1 : 3) :: cross_product
real*8 :: get_parallelogram_area
interface
function get_cross_product (vector_ab, vector_ac)
@tenpercent
tenpercent / gist:7734291
Last active December 29, 2015 22:09
type traits example
#include <iostream>
using std::cout;
using std::endl;
template<typename T>
struct TypeTraits {
static bool const IsPTR = false;
};
@tenpercent
tenpercent / it-ebooks.rb
Last active December 20, 2015 04:39 — forked from davidhq/it-ebooks.rb
Download ALL books from it-ebooks.info without prompting
require 'nokogiri'
require 'open-uri'
MARK_FILE = "mark.dat"
MAX_THREADS = 5
def wait_for_threads(threads)
print "Waiting for downloads to finish..."
threads.each { |t| t.join }
puts " ok"