Skip to content

Instantly share code, notes, and snippets.

View bzamecnik's full-sized avatar

Bohumír Zámečník bzamecnik

View GitHub Profile
@bzamecnik
bzamecnik / wordpress_com_nginx_proxy_to_subpath.md
Created June 21, 2018 12:48
Nginx proxy for Wordpress.com on custom domain with subpath.
@bzamecnik
bzamecnik / keras_prefetch_to_device.py
Last active June 20, 2018 11:17
GPU async memcpy in Keras 2.2.0 / TF 1.8 using tf.data.prefetch_to_device. It works!
# Works in Keras 2.1.0/2.2.0, TF 1.8!
import tensorflow as tf
from keras.datasets import mnist
from keras.models import Model
from keras.layers import Dense, Input, Conv2D, Flatten
from keras.utils import to_categorical
import numpy as np
import keras.backend as K
@bzamecnik
bzamecnik / compiling_tensorflow_with_avx_fma_and_mkl.md
Last active June 20, 2022 10:20
Compiling TensorFlow 1.8 with AVX2/FMA instruction and with Intel MKL

How to compile TensorFlow for CPUs with AVX2/FMA instructions or using Intel MKL?

In this tutorial we compile TF for EC2 Xeon processors and get +76 % speedup for training CIFAR10 with ResNet. In practice this might be useful for speeding up CPU inference at AWS EC2 where a GPU instance would be too costly.

Brought to you by Rossum. We automate data extraction from documents using deep learning.

Which machines?

@bzamecnik
bzamecnik / hdf5tree.py
Last active May 24, 2018 13:01
Prints HDF5 file tree.
"""
Prints HDF5 file tree.
Useful to inspect Keras weighs file.
Example usage:
python hdf5tree.py weights.h5
"""
@bzamecnik
bzamecnik / tensorpack_keras_stagingarea_cifar10.py
Created May 15, 2018 16:11
Working example of StagingArea GPU prefetch using Tensorpack + Keras.
#!/usr/bin/env python
# Author: Bohumir Zamecnik, Yuxin Wu (original example mnist-keras.py)
import tensorflow as tf
from tensorflow import keras
KL = keras.layers
"""
An example asynchronous host-to-device memcpy using a Keras model + Tensorpack.
@bzamecnik
bzamecnik / cuda_available_gpus.sh
Created April 4, 2018 21:26
CUDA next/all available GPUs
# Returns the next or all available GPU id(s), or -1 if all are busy.
# Usage:
#
# One GPU:
#
# $ CUDA_VISIBLE_DEVICES=$(available_gpu) train.sh
#
# All GPUs (comma-separated):
#
# $ CUDA_VISIBLE_DEVICES=$(available_gpu) train.sh
@bzamecnik
bzamecnik / extract_tax_confirmation.py
Last active March 31, 2018 08:39
Extracts original submission XML of CZ tax statement from digitally signed confirmation P7S
"""
Extracts original submission XML from digitally signed confirmation P7S
(Potvrzení o podání písemnosti) of the Czech tax return statement
(Daň z příjmů fyzických osob).
The confirmation is a sigitally signed XML file (P7S extension) and can be
opened using openssl (kudos to
[moldovan.IT blog](http://moldovan.it/blog/open-and-read-p7s-files-in-ubuntu-linux/)):
```
/*
Byte beats.
More info: http://canonical.org/~kragen/bytebeat/
Video: https://www.youtube.com/watch?v=gng2Gb0DHe4
Circuit:
- 8 ohm speaker on digital pin 2
- max 0.25 W, 250 ohm resistor to keep current low
@bzamecnik
bzamecnik / cudnn_compatible_gru_example.ipynb
Last active November 26, 2021 11:00
CuDNN-compatible GRU in Keras
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bzamecnik
bzamecnik / repetier_host_vnc_ubuntu.md
Created January 7, 2018 07:04
RepetierHost via VNC on Ubuntu 16.04