Skip to content

Instantly share code, notes, and snippets.

@alsrgv
alsrgv / keras_mnist_cnn.py
Created September 30, 2017 02:33
Keras with Horovod
from __future__ import print_function
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras import backend as K
import tensorflow as tf
import horovod.tensorflow as hvd
@alsrgv
alsrgv / test_nccl.c
Created November 19, 2017 17:57
Test NCCL
// Code from http://docs.nvidia.com/deeplearning/sdk/nccl-developer-guide/index.html#onedevprothrd
#define _BSD_SOURCE
#include <stdio.h>
#include "cuda_runtime.h"
#include "nccl.h"
#include "mpi.h"
#include <stdint.h>
#include <stdlib.h>
import requests
from io import BytesIO
from PIL import Image
import numpy as np
import timeit
import torch
from maskrcnn_benchmark.config import cfg
from predictor import COCODemo, to_image_list
@alsrgv
alsrgv / Tangent DL.ipynb
Last active October 19, 2019 20:35
Tangent DL
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alsrgv
alsrgv / pytorch_imagenet_resnet50_1late.py
Created July 27, 2018 18:35
1-late SGD for PyTorch ImageNet example with Horovod
from __future__ import print_function
import argparse
import torch.backends.cudnn as cudnn
import torch.nn.functional as F
import torch.optim as optim
import torch.utils.data.distributed
from torchvision import datasets, transforms, models
import horovod.torch as hvd
import tensorboardX
@alsrgv
alsrgv / numba_test.py
Created January 30, 2020 07:27
Numba CUDA jitclass question
import numba
import numba.cuda
import numpy as np
@numba.jitclass([
("x", numba.types.int32)
])
class XYZ:
def __init__(self, x):
@alsrgv
alsrgv / receptive_fields_keras.py
Last active April 1, 2020 20:50
Receptive fields for Keras
import graphviz
import numpy as np
import keras
def gather_layer_stats(layer_dict, layer, r, s):
lr, ls = None, None
if hasattr(layer, 'kernel_size'):
assert layer.kernel_size[0] == layer.kernel_size[1]
assert layer.strides[0] == layer.strides[1]
@alsrgv
alsrgv / hyperas_keras_example.py
Last active July 25, 2020 20:36
Hyperas + Horovod Example
from __future__ import print_function
from hyperopt import Trials, STATUS_OK, tpe
from hyperas import optim
from hyperas.distributions import choice, uniform, conditional
import keras
import tensorflow as tf
import horovod.keras as hvd
import keras.backend as K
import math
@alsrgv
alsrgv / pbtxt_to_pb.py
Created March 15, 2018 02:51
Converter of graph.pbtxt to binary graph.pb
from __future__ import print_function
import os
import sys
import tensorflow as tf
from google.protobuf import text_format
from tensorflow.python.framework import graph_io
if len(sys.argv) < 2:
print('Usage: %s <filename prefix>' % sys.argv[0])
@alsrgv
alsrgv / pytorch_synthetic_benchmark_apex.py
Last active January 12, 2022 12:04
Horovod-PyTorch with Apex (look for "# Apex")
from __future__ import print_function
import argparse
import torch.backends.cudnn as cudnn
import torch.nn.functional as F
import torch.optim as optim
import torch.utils.data.distributed
from torchvision import models
import horovod.torch as hvd
import timeit