TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Richard – A CNN written in C++ and Vulkan (no ML or math libs)

184 pointsby rjinmanabout 1 year ago
This started out as a personal effort to learn more about machine learning. It&#x27;s currently a CLI app where you give it a JSON file specifying your network architecture and hyperparameters and point it to your training data, then invoke it again in &#x27;eval&#x27; mode with some data it&#x27;s not seen before and it will try to classify each sample.<p>I don&#x27;t see many other people using Vulkan for GPGPU, and there may be many good reasons for that, but I wanted to try something a bit different.<p>I&#x27;ve made every attempt to make the code very clean and readable and I&#x27;ve written up the math in documentation&#x2F;math.pdf, so hopefully this is a useful learning resource for anyone interested in how neural nets work under the hood.<p>I&#x27;ll be continuing to add new features over the coming months.

11 comments

Const-meabout 1 year ago
Interestingly, I have a similar project with C# for the higher-level pieces, and Direct3D 11 GPU API instead of Vulkan: <a href="https:&#x2F;&#x2F;github.com&#x2F;Const-me&#x2F;Cgml">https:&#x2F;&#x2F;github.com&#x2F;Const-me&#x2F;Cgml</a><p>&gt; don&#x27;t see many other people using Vulkan for GPGPU, and there may be many good reasons for that<p>I think the main of these reasons is nVidia’s contributions to the ecosystem. It’s much easier to call library functions implemented by cuDNN or cuBLAS first-party library, than it is to write and dispatch compute shaders to multiply these matrices.<p>However, for use cases when hardware costs are substantial compared to software development costs, using Vulkan or D3D can be a reasonable thing to do. nVidia is too greedy, in the EULA of their drivers they forbid to use GeForce GPUs in data centres. For people who need GPGPU on their servers, that paragraph of text sometimes makes nVidia hardware an order of magnitude more expensive than AMD hardware.
Eagerabout 1 year ago
What a great project! One of my favorite things to see is when people implement as much as possible themselves. It really makes a big difference to have control over what is going on. And it is great for educational purposes of course.<p>I&#x27;m definitely going to be looking at this. Hope you had fun making it.
pjmlpabout 1 year ago
&gt; I don&#x27;t see many other people using Vulkan for GPGPU, and there may be many good reasons for that, but I wanted to try something a bit different.<p>A big reason is that C++ for Vulkan (SPIR-V) isn&#x27;t quite there, while CUDA does C, C++20 (minus modules currently), Fortran, Haskell, Java, C#, Julia, Python JITs, and anything else that might target PTX.<p>SPIR was a late response after Khronos realized the world wasn&#x27;t willing to be stuck with C for GPGPU, and the tooling is still catching up to PTX.
siesteabout 1 year ago
Very nice project, congratulations! Have you done any performance comparisons with tensorflow or pytorch?
评论 #39728933 未加载
sevaghabout 1 year ago
Lots of C++ inference code out there but this does training as well - impressive.
jeenaabout 1 year ago
That reminds me of a small project I did to classify drawings of cats and dogs 10 years ago with machine learning <a href="https:&#x2F;&#x2F;jeena.net&#x2F;catdog" rel="nofollow">https:&#x2F;&#x2F;jeena.net&#x2F;catdog</a> but no neural networks back then, just things like Canny edge detector, Hough transform, k-nearest neighbor, etc.
stanleykmabout 1 year ago
Very cool. I always find doing these kinds of toy projects is a great way of dipping your toes in the deep end of a new subject.
SomeoneFromCAabout 1 year ago
Huh. I wanted to do the same for many years, but you have actually done first. Cool!
jgordabout 1 year ago
Can you comment :<p>how well does Vulcan api fit Neural Net primitives [ matmul &#x2F; relu &#x2F; backprop &#x2F; tensor arrays ] ?<p>Also.. do you think the in-browser WebGPU api, the successor to webGL, is a good api for NN ?
评论 #39736122 未加载
olliejabout 1 year ago
I liked the original post title that left me momentarily confused going &quot;why is CNN writing articles in C++?????&quot;
RecycledEleabout 1 year ago
What is a CNN?
评论 #39742582 未加载