Skip to content

Instantly share code, notes, and snippets.

View DuaneNielsen's full-sized avatar
👾
Happy!

Duane DuaneNielsen

👾
Happy!
View GitHub Profile
@DuaneNielsen
DuaneNielsen / k_means2D.py
Created January 13, 2020 06:01
k-means 2D in pytorch
import torch
import matplotlib.pyplot as plt
"""
K means 2D demo, in pytorch
"""
n = 30 # must be even number
k = 3
@DuaneNielsen
DuaneNielsen / Short version
Last active December 1, 2019 01:05
Setting up Jupyter notebook kernels for multiple CUDA versions.
jupyter kernelspec list
Available kernels:
python2 /home/duane/PycharmProjects/.venv/imm/share/jupyter/kernels/python2
cd /home/duane/PycharmProjects/.venv/imm/share/jupyter/kernels/python2
vi kernel.json
{
@DuaneNielsen
DuaneNielsen / fixup.py
Created June 25, 2019 02:17
Implementation of Resnet trained with Fixup. No BatchNorm! https://arxiv.org/abs/1901.09321
import torch
import torch.nn as nn
from torchvision.datasets import CIFAR10
from torch.utils.data import DataLoader, random_split, Dataset, ConcatDataset
from tqdm import tqdm
from torch.optim import Adam, SGD
from torchvision.transforms import *
import statistics as stats
from pathlib import Path
from torch.nn.functional import avg_pool2d
@DuaneNielsen
DuaneNielsen / install
Last active April 29, 2019 02:00
Install small redis distrib
snap install helm --classic
/snap/bin/helm init
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
wget https://raw.githubusercontent.com/kubernetes/charts/master/stable/redis/values.yaml
vi values.yaml
#change usePassword: false
helm install stable/redis -n ppo-redis --values values.yaml
@DuaneNielsen
DuaneNielsen / notes
Created April 27, 2019 21:10
Install kubenetes using kubeadmin
install docker ce https://docs.docker.com/install/linux/docker-ce/ubuntu/
setup docker cri https://kubernetes.io/docs/setup/cri/
# Setup daemon.
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
@DuaneNielsen
DuaneNielsen / PASTE INTO CMD PROMPT
Last active April 30, 2019 22:35
Install Docker
wget -O - https://gist.githubusercontent.com/DuaneNielsen/3f021803cabd3bf70d013f566c450b96/raw/fbeeea40aa0be56098ea34cce9357292a603f15e/install_docker.sh | bash
wget -O - https://gist.githubusercontent.com/DuaneNielsen/3f021803cabd3bf70d013f566c450b96/raw/0c6915f2ceea8fa953f7c5de9825e1b2c627aa5c/config_linux.sh | bash
@DuaneNielsen
DuaneNielsen / docker.sh
Last active April 26, 2019 01:17
running Docker containers inside LXC containers
lxc launch ubuntu:bionic test
lxc exec test /bin/bash --
<install docker ce>
lxc stop test
lxc profile edit docker
lxc profile assign test docker
mount -o bind /var/lib/kubelet /var/lib/kubelet
mount --make shared /var/lib/kubelet
@DuaneNielsen
DuaneNielsen / install.sh
Last active April 20, 2021 01:09
setup microk8s
snap install --channel 1.13/stable --classic microk8s
microk8s.enable registry
microk8s.enable dns
microk8s.enable storage # not sure if i need this
#install
snap install helm --classic
/snap/bin/helm init
helm install stable/redis -n ppo-redis
snap alias microk8s.kubectl kubectl
c@ccube:~$ sudo snap install helm
helm 2.9.1 from 'snapcrafters' installed
c@ccube:~$ /snap/bin/helm init
Please copy Kubernetes config to /home/c/snap/helm/common/kube/config.
c@ccube:~$ cp /snap/microk8s/current/client.config /home/c/snap/helm/common/kube/config
c@ccube:~$ /snap/bin/helm init
Creating /home/c/snap/helm/common/repository
Creating /home/c/snap/helm/common/repository/cache
Creating /home/c/snap/helm/common/repository/local
Creating /home/c/snap/helm/common/plugins
# use 1.13 stable, it still supports docker well
snap install --channel 1.13/stable --classic microk8s
microk8s.docker build Dockerfile
microk8s.docker tag <container from last step> 127.0.0.1:32000/<name you want for container>
mickrok8s.docker push 127.0.0.1:32000/<name you want for container>
container will now be available as 127.0.0.1:32000/<name you want for container>