100x Faster Than NumPy... (GPU Acceleration)

preview_player
Показать описание
CHECK OUT MY NEW UDEMY COURSE, NOW 90% OFF WITH THIS CODE:

Code:

Old Video:

Рекомендации по теме
Комментарии
Автор

UPDATE: Thanks to @swni on Reddit for the suggestion to use the `ids_pairs` array to index to get `x_pairs` and `y_pairs` as opposed to reusing the `torch.combinations` function. This reduces the simulation time required for 10000 particles to only 20 seconds (about half what is shown in the video). Code has been updated on GitHub!

To compare NumPy and PyTorch fairly under these new conditions, I simulate 5000 particles in each case. PyTorch takes 6.3 seconds to run (remember, it also has around a 2 second overhead), while NumPy takes about 823 seconds, indicative of about a 100x increase.

MrPSolver
Автор

Bro please never stop doing physics videos, they are amazing! I know they are not the most popular videos in your channel but they are super helpful for someone that only had one programming subject and was with Fortran :( . Greetings from the Dominican Republic! haha

fabiopimentel
Автор

It always catches me off guard to see non-meme videos from you. I am more into web-interacting services rather than data manipulation/science—so async is my wheelhouse rather than this stuff. Still fascinating to watch.

ConstantlyDamaged
Автор

Awesome vid! Love seeing Pytorch being leveraged for its first class GPU support for things other than machine learning. If I recall correctly, someone had a blog post about using pytorch to optimize a shape for rolling (i.e. reinventing the wheel) and it used pytorch, super funny, but cool. Great video!!

zb
Автор

Congrats! Great video! Please, don't stop, your videos are incredibly didactic! I allways cite your channel to my students in my Classical Dynamics classes.

tiberioborgesvale
Автор

I am a numerical physicist, and this will be very helpful for me. I am currently running all my simulations om CPU (though using MPI for parallellization)

EVL
Автор

first non-humour vid i see and its awesome! will try to learn more! thank you professor!

samlaki
Автор

Amazing content.
I had a professor when I was in the physics degree that told us about the power of GPU when coding "big numbers". The GPUs have up to 1000 more ("dumb") cores than the CPU and that can be really powerfull. I am now working on my PhD and I use python to do the work. I think that I can learn a lot from you.
Thank you!

antonioarroyopolonio
Автор

I absolutely love this. I'm making my own game engine (fun hobby, tbh) with OpenGL, numpy and Python, and for some time I've thought about where to simulate my physics. This is an eye-opener, and it looks fun as heck! Espec. the matplotlib animation for some "lazy" collision simulations. This vid brings me straight to my college days

Impo
Автор

Very interesting content and I really appreciate the way you show both notebooks side by side to compare the results. Thank you very much!

gabrielzinatorosa
Автор

Great video, thanks! Consider using indexing by the coordinates of particles in space. The idea is that the coordinates of the particles are rounded to the size of the box, and the collision check occurs only for those particles that are inside the same box. This usually reduces the number of pairs by 90%.

Ilya-iuih
Автор

I'm honored that your stuff comes up on my feed. Amazing work!

Nooreazy
Автор

Nice I've been waiting for this one ! thanks, looking forward to seeing the next ones

Louis-mlzr
Автор

Great educational video, mate! I'm a CS Grad student and was beginning to get to the later ML courses. Your explanation and side-by-side logic demonstration with Numpy convinced me to do a bit of research and switch from TF to Pytorch! Thanks so much!! I eagerly look forward to the next video!

bwallace
Автор

Dude a GPU accelarated python series would be amazing 😍😍😍

shamaldesilva
Автор

GPU takes advantage of linear operations. So I'm not really sure, but if you use some data structures like quadtree the complexity of the computation might drastically simplify. And you won't need to calculate all n² distances. In fact most particles are not collading with each other. One need to test it, but with that CPU might still outperform the overhead of the GPU, since there won't be that many computations.

tunafllsh
Автор

Super cool, your meme videos are hilarious but this quality content is why I subbed in the first place

Thierry
Автор

Very interesting, would love to see more of this!

MyMinecrafter
Автор

12:00 why don't you simply use torch.cdist (if you have a batch of vectors, otherwise use torch.pdist) which calculates the p-norm (p=2 in your case) distance between each pair of the two collections of row vectors. This is supposed to be much faster than your code, even though I didn't test it.

omarllama
Автор

Thanks, now I finally will have one reason to tell my dad to buy me a graphics card😂

btr_Z