Skip to content

Instantly share code, notes, and snippets.

@jnordberg
Last active February 13, 2017 00:27
Show Gist options
  • Save jnordberg/1af8005dacd2b45cb3af1b5e57d17dca to your computer and use it in GitHub Desktop.
Save jnordberg/1af8005dacd2b45cb3af1b5e57d17dca to your computer and use it in GitHub Desktop.
neural video memory usage
{"description":"neural video memory usage","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.coffee":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/mvHvFgj.gif","inline-console":true}
# video memory on test card
testVmem = 3.2 # gb
testMaxRes = [892, 502]
testPerf = 4283
testTimePerFrame = 155
# with another optimizer, lower memory usage but results not as good
#testVmem = 2.2
# video memory on prod card
prodVmem = 12
prodPerf = 10835
# solve for prodMaxRes, assuming linear memory scale
gbPerPixel = testVmem / (testMaxRes[0] * testMaxRes[1])
prodMaxPixels = prodVmem / gbPerPixel
aspect = 16/9
side = Math.sqrt prodMaxPixels
prodMaxRes = [side * aspect, side]
mod = Math.sqrt aspect
prodMaxRes[0] /= mod
prodMaxRes[1] /= mod
prodTimePerFrame = 1
timePerPixel = testTimePerFrame / (testMaxRes[0] * testMaxRes[1])
timePerPixel *= testPerf / prodPerf # adjust for performance difference
prodTimePerFrame = timePerPixel * prodMaxPixels
# target resolutions
r1080p = [1920, 1080]
r720p = [1280, 720]
# viz
svg = d3.select 'svg'
drawScale = 1/3
cat10 = d3.scale.category10()
resolutions = []
resolutions.push
res: prodMaxRes
label: "Titan X - #{ prodVmem }gb #{ Math.round prodTimePerFrame }s"
color: cat10 2
resolutions.push
res: testMaxRes
label: "GRID K520 - #{ testVmem }gb #{ Math.round testTimePerFrame }s"
color: cat10(1)
resolutions.push
res: r720p
label: "720p"
color: 'none'
resolutions.push
res: r1080p
label: "1080p"
color: 'none'
resolutions.sort (a, b) -> (b.res[0] * b.res[1]) - (a.res[0] * a.res[1])
sel = svg.selectAll 'g'
.data resolutions
.enter()
.append 'g'
sel.append 'rect'
.attr 'x', 17
.attr 'y', 17
.attr 'fill', (d) -> d.color
.attr 'stroke', (d) -> if d.color is 'none' then 'rgba(0,0,0,0.2)' else 'black'
.attr 'width', (d) -> d.res[0] * drawScale
.attr 'height', (d) -> d.res[1] * drawScale
sel.append 'text'
.text (d) -> d.label
.attr 'dx', (d) -> 23
.attr 'text-anchor', 'start'
.style 'font-size', 12
.attr 'dy', (d) -> (d.res[1] + 26) * drawScale
sel.append 'text'
.text (d) -> d.res.map(Math.round).join('x')
.attr 'dx', (d) -> (d.res[0] + 21) * drawScale
.attr 'text-anchor', 'end'
.style 'font-size', 12
.attr 'dy', (d) -> (d.res[1] + 26) * drawScale
clips = [
{fps: 30, res: r720p, length: 1}
{fps: 30, res: prodMaxRes, length: 1}
{fps: 30, res: r1080p, length: 1}
]
clips.forEach (d) ->
numFrames = d.length * 60 * d.fps
frameTime = d.res[0] * d.res[1] * timePerPixel
d.time = numFrames * frameTime
sel2 = svg.append 'g'
.attr 'transform', "translate(20, #{ (resolutions[0].res[1] + 150) * drawScale })"
.selectAll 'g'
.data clips
.enter()
.append 'g'
.attr 'transform', (d, i) -> "translate(0, #{ i * 125})"
sel2
.append 'text'
.attr 'text-anchor', 'start'
.style 'font-size', 16
.text (d) -> "
Render times for a #{ d.length } minute #{ d.res.map(Math.round).join 'x' }@#{ d.fps } clip
"
sel2.selectAll 'text.node'
.data [1, 2, 4, 8, 16, 32]
.enter().append 'text'
.attr 'text-anchor', 'start'
.style 'font-size', 12
.attr 'dy', (d, i) -> 17 + i * 15
.text (d) ->
pd = d3.select(@parentNode).datum()
rv = "#{ d } node"
rv += 's' if d > 1
t = pd.time / d / 60 / 60
rv += " #{ Math.round t }h"
rv += " (#{ Math.round(t / 24)} days)" if t > 48
return rv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment