sym_num

sym_num

Hello
I started new project.
It uses cuBLAS to calculate matrix products.
It uses NIFs.
I want to apply it to Deep Learning.
https://github.com/sasagawa888/cumatrix

First 10 of 10 Posts Switch mode

sym_num

sym_num OP

I wrote addition, subtraction and multiplication code in CUDA and cuBLAS. So I measured it and compared it with the Matrix library.
Multiplication is fast, but addition and subtraction are not much different.

------ cuMatrix ----------------
iex(1)> a = Cumatrix.new(1000,1000,:rand);0
0
iex(2)> b = Cumatrix.new(1000,1000,:rand);0
0
iex(3)> require(Time)
nil
iex(4)> Time.time(Cumatrix.mult(a,b));0
“time: 226896 micro second”
“-------------”
0
iex(5)> Time.time(Cumatrix.mult(a,b));0
“time: 67511 micro second”
“-------------”
0
iex(6)> Time.time(Cumatrix.mult(a,b));0
“time: 33814 micro second”
“-------------”
0
iex(7)> Time.time(Cumatrix.add(a,b));0
“time: 24058 micro second”
“-------------”
0
iex(8)> Time.time(Cumatrix.add(a,b));0
“time: 31787 micro second”
“-------------”
0
iex(9)> Time.time(Cumatrix.add(a,b));0
“time: 28815 micro second”
“-------------”
0
iex(10)> Time.time(Cumatrix.sub(a,b));0
“time: 27208 micro second”
“-------------”
0
iex(11)> Time.time(Cumatrix.sub(a,b));0
“time: 25860 micro second”
“-------------”
0
iex(12)> Time.time(Cumatrix.sub(a,b));0
“time: 24574 micro second”
“-------------”
0

------ Matrix ---------------------
iex(1)> a = Matrix.rand(1000,1000);0
0
iex(2)> b = Matrix.rand(1000,1000);0
0
iex(3)> require(Time)
nil
iex(4)> Time.time(Matrix.mult(a,b));0
“time: 29913660 micro second”
“-------------”
0
iex(5)> Time.time(Matrix.mult(a,b));0
“time: 30599437 micro second”
“-------------”
0
iex(6)> Time.time(Matrix.mult(a,b));0
“time: 30030455 micro second”
“-------------”
0
iex(7)> Time.time(Matrix.add(a,b));0
“time: 21835 micro second”
“-------------”
0
iex(8)> Time.time(Matrix.add(a,b));0
“time: 84429 micro second”
“-------------”
0
iex(9)> Time.time(Matrix.add(a,b));0
“time: 76458 micro second”
“-------------”
0
iex(10)> Time.time(Matrix.sub(a,b));0
“time: 22082 micro second”
“-------------”
0
iex(11)> Time.time(Matrix.sub(a,b));0
“time: 25556 micro second”
“-------------”
0
iex(12)> Time.time(Matrix.sub(a,b));0
“time: 25680 micro second”
“-------------”
0

elcritch

elcritch

You should try out Matrex as well. GitHub - versilov/matrex: A blazing fast matrix library for Elixir/Erlang with C implementation using CBLAS. · GitHub.

IIRC, you can pass cuBLAS at build time as the target blas library. With noblas option I was getting Matrix dotting about 10% faster than numpy on my Mac. I’d be curious to learn how it compares with cuBLAS.

sym_num

sym_num OP

I use Matrex with my own library of deep learning. Matrex is great. I use Matrex with Deep Pipe.
https://github.com/sasagawa888/DeepPipe

elcritch

elcritch

Nice! I saw DeepPipe earlier but didn’t realize it used Matrex. I’ll have to take a look into it! It’s just a layer for building simple NN like porting (simple) tensor flow models over?

Out of curiosity, are you experimenting with cuBLAS for speed or do you have to manually write .cu code to
wrap cuBLAS? I think you could write a more efficient gradient descent using that approach.

sym_num

sym_num OP

Thank you.
Deep Pipe was written for me to understand DL. It can run only about MNIST.

GPU was indispensable for runing DL in practical use. But, I could not find the library. So I decided to make it myself. cuMatrix is still experimental. I plan to make improvements as engine for the Deep Pipe.

kip

kip

ex_cldr Core Team

Sasawaga-san, I think you are doing some of the most interesting work in the Elixir ecosystem. I hope one day to understand it all but I know its very valuable to our community. It looks like a potential path to making Elixir a more valuable platform in ML.

Please keep going!

sym_num

sym_num OP

Thank you very much.
It is very encouraging.

sym_num

sym_num OP

I was encouraged.
The loss function, the activation function, and the differential calculation are also added. I will start GPU version of Deep Pipe2.

sym_num

sym_num OP

I have updated to the latest version of Elixir ver1.10. I have modified cuMatrix to work.

sym_num

sym_num OP

I improved the data structure with reference to Matrex code. Speed up.
Thanks to Mr. versilov.

iex(1)> m = Cumatrix.new([[1.0,2.0],[3.0,4.0]])
{2, 2, <<0, 0, 128, 63, 0, 0, 64, 64, 0, 0, 0, 64, 0, 0, 128, 64>>}
iex(2)> Cumatrix.print(Cumatrix.mult(m,m))
7.000000 10.000000
15.000000 22.000000

true
iex(3)> a = Cumatrix.rand(1000,1000);0
0
iex(4)> b = Cumatrix.rand(1000,1000);0
0
iex(5)> require(Time)
Time
iex(6)> Time.time(Cumatrix.mult(a,b));0
“time: 14599 micro second”
“-------------”
0
iex(7)> Time.time(Cumatrix.mult(a,b));0
“time: 12263 micro second”
“-------------”
0
iex(8)> Time.time(Cumatrix.mult(a,b));0
“time: 11781 micro second”

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 91898 914
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
New
byu
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project. My initial shotgu...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
AstonJ
Just a general thread to post chat/news/info relating to AI/ML stuff that may be relevant for Nx now or in the future. Got anything to sh...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
mudasobwa
While I am working on the Language Agnostic Code Audit SaaS, which uses MetaAST (spoiler: I am expecting it to be in a good shape for ann...
New

We're in Beta

About us Mission Statement