Skip to content

Instantly share code, notes, and snippets.

View pgagarinov's full-sized avatar

Peter Gagarinov pgagarinov

View GitHub Profile
@pgagarinov
pgagarinov / npuint8_torchfloat32.py
Created December 22, 2020 22:47 — forked from xvdp/npuint8_torchfloat32.py
numpy uint8 to pytorch float32; how to do it efficiently
""" I was writing a dataloader from a video stream. I ran some numbers.
# in a nutshell.
-> np.transpose() or torch.permute() is faster as uint8, no difference between torch and numpy
-> np.uint8/number results in np.float64, never do it, if anything cast as np.float32
-> convert to pytorch before converting uint8 to float32
-> contiguous() is is faster in torch than numpy
-> contiguous() is faster for torch.float32 than for torch.uint8
-> convert to CUDA in the numpy to pytorch conversion, if you can.
-> in CPU tensor/my_float is > 130% more costly than tensor.div_(myfloat), however tensor.div_()
does not keep track of gradients, so be careful using it.
@pgagarinov
pgagarinov / sysctl-proxmox-tune.conf
Created June 14, 2020 15:21 — forked from sergey-dryabzhinsky/sysctl-proxmox-tune.conf
Most popular speedup sysctl options for Proxmox. Put in /etc/sysctl.d/
###
# Proxmox or other server kernel params cheap tune and secure.
# Try it if you have heavy load on server - network or memory / disk.
# No harm assumed but keep your eyes open.
#
# @updated: 2020-02-06 - more params used, adjust some params values, more comments on params
#
### NETWORK ###