Skip to content

Instantly share code, notes, and snippets.

@lopuhin
lopuhin / RPython traceback and lldb backtrace.txt
Last active March 3, 2019 15:04
cpyext_tp_new_tuple error: pytorch + pypy3.6
$ python
Python 3.6.1 (dab365a46514, Feb 05 2019, 16:36:40)
[PyPy 7.0.0-alpha0 with GCC 6.2.0 20160901] on linux
$ lldb python -- -c 'import torch'
(lldb) target create "python"
Current executable set to 'python' (x86_64).
(lldb) settings set -- target.run-args "-c" "import torch"
(lldb) run
Process 9293 launched: '/home/kostia/ml/pytorch/pypy3.6-v7.0.0/bin/python' (x86_64)
@lopuhin
lopuhin / resnet_mkldnn.py
Created June 6, 2019 18:27
Faster ResNet CPU inference with MKLDNN + PyTorch 1.1
$ pip install torch==1.1.0 torchvision==0.3.0
$ OMP_NUM_THREADS=1 ipython
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
In [1]: import torch
...: from torchvision.models import resnet50
In [2]: def forward(m, x):
...: """ resnet without average pooling """
...: x = m.conv1(x)
import os
os.environ['OMP_NUM_THREADS'] = '1'
import argparse
import resource
import sys
import time
import numpy as np
import torch
from torch import nn
@lopuhin
lopuhin / pytorch_high_mem.py
Created October 15, 2019 10:06
pytorch high memory usage on CPU inference with variable input shapes
import os
os.environ['OMP_NUM_THREADS'] = '1'
import argparse
import resource
import sys
import time
import numpy as np
import torch
from torchvision.models import resnet34