Learn to use a CUDA to dramatically speed up code in Python

Python Book

The first thing to understand is that normal Python code cannot use GPU acceleration, only programs designed for the GPU can be run on the GPU. Hardware acceleration must be implemented in hardware language.

GPU concept correlation
Graphics Processing Unit (GPU) : a visual processor or Graphics display card.

GPU is responsible for rendering 2D, 3D and VR effects, mainly focusing on computer graphics and image field. Gpus have since been found to be well suited for parallel computing, speeding up modern scientific computing and moving beyond games and video.

No matter CPU or GPU, it is necessary to use Core (ALU+ register) to do arithmetic logic operation when performing calculation.

A core can only perform a certain task sequentially. In order to process more tasks in parallel at the same time, chip companies have developed a multi-core architecture. As long as there is no dependence between each other, each core does its own thing and the multi-cores do not interfere with each other, the effect of parallel computing can be achieved.

The limitations of the CPU
A PC CPU has only 2 to 8 cores, and a data server only has 20 to 40 cores, while a GPU has thousands of cores.

However, the CPU and GPU core are not the same, the GPU core can only focus on certain features of the task, while the CPU core has a wider range of computing power.

The CPU is more general, playing a role of coordination and management, while the GPU is limited to computing specific tasks.

The CPU reads and writes data from Main Memory and interacts with the GPU through the Bus.

In addition to many computing cores, gpus also have their own independent storage, called video memory.

GPU core in the calculation, can only directly read and write data from the video memory, programmers need to specify in the code which data need to be copied between memory and video memory, these data transmission is on the bus, so the bus (NVLink technology, PCI-E technology…) Transmission speed and bandwidth can also be bottlenecks for some computing tasks.

Because CPU and GPU are separate, in Nvidia's design philosophy, CPU and main memory are called hosts and GPU is called Device.

Use a combination of CPU and GPU to speed up computation, also known as heterogeneous computing.

The Summit, the world's no. 1 supercomputer, uses 9,216 IBM POWER9 cpus and 27,648 Nvidia Tesla Gpus.

When GPU is introduced, the calculation process becomes:

Class and copy the necessary data to the graphics memory of the GPU device.
The CPU invokes the GPU function to enable multiple GPU cores to compute at the same time.
CPU and GPU perform asynchronous computing.
Copy the GPU calculation result back to the host to obtain the calculation result.

The basic flow of CUDA programming is as follows:

Class and copy the necessary data to the graphics memory of the GPU device.
CUDA kernel functions are called with some granularity of parallelism using an execution configuration.
The CPU and GPU perform asynchronous computing.
Copy the GPU calculation results back to the host.


  1. Abertpails

    коли закінчиться війна в україні 2022 скільки може тривати війна в україні в той день коли закінчиться війна

  2. Abrtpails
  3. Abrtpails
  4. Abrtpails
  5. Abrtpails
  6. auto detailing overland park

    Say, you got a nice blog.Much thanks again. Keep writing.


  7. Abrtpails
  8. Abrtpails
  9. Abrtpails
  10. Abrtpails
  11. Abrtpails
  12. Abrtpails
  13. Abrtpails
  14. Abrtpails
  15. Abrtpails
  16. Abrtpails
  17. Abrtpails
  18. Abrtpails
  19. Abrtpails
  20. Abrtpails
  21. Abrtpails
  22. ambbet

    Im obliged for the article.Much thanks again. Really Cool.


  23. perth web design
  24. purple venus butterfly

    Im grateful for the post.Much thanks again. Really Great.


  25. Source
  26. Holistic Health

    Enjoyed every bit of your blog post.Much thanks again. Awesome.


  27. how to mold his penis using a dildo with balls

    I am so grateful for your blog article.Much thanks again. Much obliged.


  28. flower crown

    Fantastic blog post.Really thank you! Really Great.


  29. akwam

    Wow, great post. Cool.


  30. Yoga

    Awesome article post.Thanks Again. Cool.


  31. Abundance

    I appreciate you sharing this article post.Really thank you! Really Great.


  32. Kelvin Kaemingk

    Thanks so much for the blog. Cool.


  33. https://s3.amazonaws.com/potchefstroom1/tree-felling/index.html

    Enjoyed every bit of your blog. Keep writing.


  34. delta8 softgels

    Major thankies for the post. Keep writing.


  35. realistic cumming dildo

    I really like and appreciate your post.Really thank you! Fantastic.


  36. mold inspection greenville sc

    Major thankies for the blog post.Really thank you! Keep writing.


  37. garden patio

    I cannot thank you enough for the blog. Awesome.


  38. Holistic

    A round of applause for your blog post.Really thank you! Really Cool.


  39. 토토사이트 검증

    Awesome post.Thanks Again.


  40. rxce

    wow, awesome article post.Much thanks again. Will read on...


  41. Home survey

    Thanks-a-mundo for the article.Thanks Again. Want more.


  42. jakuzili süit oda istanbul

    wow, awesome article. Great.


  43. Download Lagu Mp3 Still Life Bigbang

    Very informative post.Thanks Again.


  44. Holistic
  45. laundry renovations melbourne

    This is one awesome blog post.Really looking forward to read more. Much obliged.


  46. donlod lagu

    Very good blog.Really thank you! Will read on...


  47. source

    I think this is a real great article.Really thank you! Keep writing.


  48. aplikasi penghasil uang

    Having read this I thought it was rather informative. I appreciate you spending some time and effort to put this content together. I once again find myself spending a lot of time both reading and leaving comments. But so what, it was still worthwhile.



    This is one awesome blog.Much thanks again. Want more.


  50. rysupaudio

    I appreciate you sharing this article post.Really thank you! Awesome.


  51. download lagu

    I seriously love your website.. Pleasant colors & theme. Did you make this web site yourself? Please reply back as I’m trying to create my very own site and would like to know where you got this from or just what the theme is named. Many thanks!


  52. legit fake ids

    I value the article.Much thanks again. Much obliged.


  53. fag bearing

    Enjoyed every bit of your article post. Keep writing.


  54. best stroker for men

    Thanks for sharing, this is a fantastic article post.Really thank you! Really Cool.


  55. adam and eve g spot vibrator

    Thanks again for the article.Much thanks again. Want more.


  56. how to fix blue balls

    I am so grateful for your article.Thanks Again. Great.


  57. rummy wealth apk

    I loved your article post.Really looking forward to read more. Really Great.


  58. rxce apk

    I cannot thank you enough for the blog. Keep writing.


  59. rummy gold

    Thanks for sharing, this is a fantastic blog post.Really looking forward to read more.



Related recommendation

No related articles!


Learn to use a CUDA to dramatically speed up code in Python