Skip to content

Instantly share code, notes, and snippets.

View ksopyla's full-sized avatar

Krzysztof Sopyła ksopyla

View GitHub Profile
@wphicks
wphicks / Fraud_Detection_Example.ipynb
Last active January 28, 2023 12:44
Notebook example for fraud detection with the Triton FIL Backend
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Htop
sudo apt install -y htop
# Byobu
sudo apt install -y byobu
# Gdebi
sudo apt install -y gdebi-core
# GIT
@jmp84
jmp84 / export.py
Created September 16, 2020 06:11
TorchScript MT model
import argparse
import logging
import torch
from fairseq.checkpoint_utils import load_model_ensemble_and_task
from fairseq.sequence_generator import SequenceGenerator
def get_args():
parser = argparse.ArgumentParser(
import itertools
import torch
from torchtext.experimental.datasets.translation import DATASETS, TranslationDataset
from torchtext.vocab import build_vocab_from_iterator
from torchtext.experimental.functional import (
vocab_func,
totensor,
sequential_transforms,
)
from torchtext.data.utils import get_tokenizer
@mingfeima
mingfeima / pytorch_cpu_perf_bkm.md
Last active February 16, 2024 21:31
BKM for PyTorch CPU Performance

General guidelines for CPU performance on PyTorch

This file serves a BKM to get better performance on CPU for PyTorch, mostly focusing on inference or deployment. Chinese version available here.

1. Use channels last memory format

Right now, on PyTorch CPU path, you may choose to use 3 types of memory formats.

  • torch.contiguous_format: default memory format, also referred as NHCW.
  • torch.channels_last: also referred as NHWC.
  • torch._mkldnn: mkldnn blocked format.
@mingfeima
mingfeima / bert_optimization.md
Last active July 8, 2022 06:13
BERT Optimization

benchmark

Based on huggingface repo for performance evaluation, actual benchmark run script placed at repo. How to reproduce performance:

  1. prepare dataset according to link.
  2. update GLUE_DIR to actual dataset path in run_inference.sh.
  3. change env settings, the default setting is using 20 cores;

MKL v.s. MKLDNN

Inference performance result on Xeon 6148 (2x20 cores), single socket and single thread.

@akiross
akiross / Convolutional Arithmetic.ipynb
Last active March 12, 2024 16:31
Few experiments on how convolution and transposed convolution (deconvolution) should work in tensorflow.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vinhkhuc
vinhkhuc / min-char-rnn-tensorflow.py
Last active May 17, 2019 02:48
Vanilla Char-RNN using TensorFlow
"""
Vanilla Char-RNN using TensorFlow by Vinh Khuc (@knvinh).
Adapted from Karpathy's min-char-rnn.py
https://gist.github.com/karpathy/d4dee566867f8291f086
Requires tensorflow>=1.0
BSD License
"""
import random
import numpy as np
import tensorflow as tf
@Reddine
Reddine / install.sh
Last active January 10, 2022 10:12
Install Theano on Ubuntu 14.04
sudo apt-get install build-essential
sudo apt-get update
# BLAS → LAPACK → ATLAS → numpy → scipy → Theano
# remove numpy and scipy
sudo apt-get remove python-numpy
sudo apt-get remove python-scipy
# Instalation commands
sudo apt-get install gfortran
sudo apt-get install libopenblas-dev
sudo apt-get install liblapack-dev
@afolarin
afolarin / resource_alloc_docker.md
Last active March 18, 2024 17:01
Resource Allocation in Docker

#Container Resource Allocation Options in docker-run

now see: https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources

You have various options for controlling resources (cpu, memory, disk) in docker. These are principally via the docker-run command options.

##Dynamic CPU Allocation -c, --cpu-shares=0
CPU shares (relative weight, specify some numeric value which is used to allocate relative cpu share)