Timing TensorFlow.js on different systems

Hey all, I need your help :). I would like to performance-test some things on as many different machines as possible.

TL;DR
Please go to https://n2g.claude-apps.com/tfjs-speedtest/index.html, wait for the run to finish, and copy-paste the result into this thread, together with info about your machine (Ideally CPU-speed and GPU cores/speed, but just “2019 Dell XPS 13” or even “midrange 2021 laptop” would do. I’m interested in any machine, from an RPI to a RTX 4090 gaming PC.

Background:
I’m playing around with running YoloV8 in the browser. I trained a model that detects Little Auks (bird from the Polar regions; my girlfriend is studying them, and I’m an unpaid intern :)).

It’s possible to export such a model to TensorFlow.JS, which means you can run it in the browser (meaning you could program it so that you can just drag in a video-file, and yolo-detection will start 100% client-side, without any uploading).

There are three ways in which the system can run: cpu (meaning plain javascript), wasm (optimised webassembly) and webgl (on the GPU).

I want to get some sort of idea on how fast things run on different kinds of hardware. Performance is great on my MacBook Pro M2 Max, but I don’t think I can expect everyone in the world to have a computer like that :).

To be completely clear: this test will only eat up some CPU/GPU cycles on your machine (and download about 60MB of data, mostly the model (12MB) and the images on which the test is run). After you close the browser window, nothing remains.

The test has 2 parts: first it will run Yolo on 20 images using the tensorflow.js WASM code. Afterwards it will do the same using the tensorflow WebGL code.

On my MBP it takes about 15 seconds to run the whole test (after the model and images are downloaded).

During the run you will see the result of the detection (see image). The pink boxes are the result of the detection (so calculated and drawn in the browser).

Once done, results look like this. Basically it’s the number of milliseconds per image (for wasm and webgl), your userAgent string, and the tensorflow.js environment. If you use something to obfuscate your userAgent string, please let me know what browser you used :slightly_smiling_face:

Afterwards, please send me the results in here. If I copy-paste the results into discord, it makes it a nice attachment :). Please let me know in the same message what computer you used (e.g. 2023 Macbook M2 Max (14 inch), 12 cores, 30 GPU cores).

message.txt

(and obviously, please don’t do bitcoin mining, or play a 3d game, while doing this test :))

Things I’ve found out so far: Safari is actually twice as fast on the WASM-run as Chrome (but webgl is equally fast).

And this even runs on my iPhone 13 pro… WASM is only 50% slower than on MBP safari (so still quicker than Chrome). WebGL is about 1/3rd as fast.

message.txt

what birds are these?

CPU: Intel® Core™ i7-7700K CPU @ 4.20GHz × 8
GPU:
Specifications GTX 1050 Ti KalmX
Graphics Clock Base Clock 1290MHz / Boost Clock 1392MHz
Memory Clock 3500MHz (DDR 7000MHz)
CUDA Cores 768
Memory Bandwidth (GB/sec) 112

I tested the 4 browsers I have currently installed. Biggest suprise - Palemoon. The first set of tests was almost as quick as the second except for the first images that took much longer. Maybe it’s some sort of on-the-fly optimization?

Brave.txt

Chromium.txt

Firefox.txt

Palemoon.txt

(for context, it’s a Linux machine used as a desktop/gaming station, but I used to donate computing power to projects such as BOINC and GPU Grid, until my financial situation and rising electricity prices forced me to stop… but long story short, thing is built to be super quiet while still having decent computing power)

Reactions: :+1: ×1 (Claude)

Great, many thanks! Yes, first image on WebGL the shaders are compiled. On a production system, you always do a first run with a completely black image just to compile the shaders. That’s why the first image is slow.

Well, it looks like Palemoon used WebGL even in the wasm test.

Wow yeah! That’s super weird…

Only think I can think of is that it somehow doesn’t support WASM and then tensorflow falls back to webgl… But I cannot find anything about this online…

And here I was hoping it’s some sort of optimization on Palemoon’s side to use GPU behind the scenes xD

Well, I found this in Palemoon’s settings. It was on when I did the test, so dunno.

Screenshot_at_2023-08-03_18-49-55.png

Would be a bit of a crappy optimisation, since I explicitly tell it to use WASM. Now I guess in theory it’s possible that the system has such an amazing WASM JIT compiler that it sends the whole thing to the GPU anyways, but I’m quite sure such a compiler hasn’t been invented yet ;).

Must be a bug somewhere (maybe my code, maybe tensorflow, maybe palemoon)

BTW never heard of the browser before, but I like their attitude