Live data from Hacker News

MNIST training: Showdown between JavaScript and WebAssembly

ai.danruta.co.uk

21–30 of 34 posts

Re: MNIST training: Showdown between JavaScript and WebAssembly

#21
post #8
post #2

If you care about performance use GPU shaders.

If you care about performance, don't use JS for training neural networks.

Not everything requires a multiple layer NN to be trained. It is not optimal, sure, but it might open up different possibilities

Re: MNIST training: Showdown between JavaScript and WebAssembly

#23
post #7
post #6

It would be a more fair comparison to https://deeplearnjs.org/ , since CPU training is not standard practice for neural nets these days.

We've done some initial tests ourselves. WASM doesn't yet support SIMD so WebGL tends to be 5-10x faster. SIMD is actively being worked on by many smart people in Chromium / other browsers, so I would expect to see huge wins in the near term future. When that happens, deeplearn.js will have a WASM backend. WASM has a much better memory management story (destructors on the C++ side) so I'm super excited about its futu…

GPUs are at least an order of magnitude faster at training neural nets than CPUs. This is why companies like Google very large amounts of multi-thousand dollar GPUs like the Tesla V100. If cpu WASM is ever faster than WebGL, it's just that the webGL implementation is suboptimal (or that WebGL has too much overhead for real GPU compute)

Re: MNIST training: Showdown between JavaScript and WebAssembly

#25
post #4
post #2

If you care about performance use GPU shaders.

https://github.com/pair-code/deeplearnjs

My comment was meant to imply that if you're using JS, then you already care about other things _more_ than you care about performance.

Once you've decided that you do care about those other things, then getting the best performance you can is great and deeplearnjs is very useful.

But if what you care about most is performance, then using JS is not the way to go. I'm guessing deeplearnjs is an order of magnitude slower (at least) for training a modern convnet relative to cudnn or MKL. And I don't think it's currently possible to use multiple GPUs? Although you could imagine some crazy distributed asynchronous training running in browsers all over the world.

Re: MNIST training: Showdown between JavaScript and WebAssembly

#26
PLEASE NOTE

This is NOT a fair and honest comparison.

The WebAssembly implementation pegs 100% of one CPU core (as monitored in htop) on my system until it is completed.

The JS button sits between 66.2%-66.8% and 19-26% of one core depending on whether the tab is focused or not.

The JS version does not use Web Workers. I can, however, see two references to setTimeout(). This leads me to assume that the JS version is being slowed down so that the UI does not lock up.

Completely understandable, but patently dishonest, as there is no mention of this fact on the webpage.

The JS version should be reimplemented so it can run at 100% speed.

Re: MNIST training: Showdown between JavaScript and WebAssembly

#27
post #3

I compiled hello world in Rust into wasm the other day for the first time and it was incredibly satisfying for whatever reason. New technology is fun I guess. Note: This page isn't rendering properly on iPhone

We're working on making it even easier! Expect news soonish.

Re: MNIST training: Showdown between JavaScript and WebAssembly

#28
post #26

PLEASE NOTE This is NOT a fair and honest comparison. The WebAssembly implementation pegs 100% of one CPU core (as monitored in htop) on my system until it is completed. The JS button sits between 66.2%-66.8% and 19-26% of one core depending on whether the tab is focused or not. The JS version does not use Web Workers. I can, however, see two references to setTimeout(). This leads me to assume that the JS version is…

It's still an order of magnitude slower though at least on my machine

Re: MNIST training: Showdown between JavaScript and WebAssembly

#29
post #28
post #26

PLEASE NOTE This is NOT a fair and honest comparison. The WebAssembly implementation pegs 100% of one CPU core (as monitored in htop) on my system until it is completed. The JS button sits between 66.2%-66.8% and 19-26% of one core depending on whether the tab is focused or not. The JS version does not use Web Workers. I can, however, see two references to setTimeout(). This leads me to assume that the JS version is…

It's still an order of magnitude slower though at least on my machine

Same here too. I just think it's dishonest that there's no mention that the JS version is being throttled while the wasm version is not.

Re: MNIST training: Showdown between JavaScript and WebAssembly

#30
post #11
post #10

My browser at least seems to struggle to download the file at https://ai.danruta.co.uk/webassembly/mnist.js - how big is this file in total?

It is 20 Megabytes, transmitted gzipped at 2.4 Megabytes. It is super slow to grab though, due to the other end.

Yep, running this on a 2 year old raspberry pi, on my desk, haha
Post reply on HN