0
$\begingroup$

Even with ample knowledge about the low computational performance that Python has, and even though it is an interpreted language that is not recommended for real-time applications, it is the technology that I see most companies looking for professionals in AI. I am curious, because many tests over the internet show that, for example, C++ performs processing more than 100 TIMES! faster than Python, what is the explanation for companies still using this technology for AI, exactly an area that requires so much computational performance?

$\endgroup$
3
$\begingroup$

I think it's because the actual computation isn't being done by Python, but with the optimized libraries (like tensorflow) that are built with low level programming languages. The only parts that Python is being used for is the basic program structure and getting the data into the high performance machine learning libraries.

Also Python is more like a scripting language so it's a lot faster writing programs with it than in C++, so there's less development time, so you can hire a couple Python developers for your machine learning instead of a huge team for a complicated C++ project.

| improve this answer | |
$\endgroup$
  • $\begingroup$ At least that's what I think my tutor was trying to get across, let me know if it's incorrect. $\endgroup$ – temp Jan 24 at 0:33
  • $\begingroup$ Also worth noting comparing python and c is only applicable in rudimentary cases, as most of the time for serious work with ML, you're using the GPU, where your only option is really CUDA. So then it just becomes a matter of what implements the very low level code of CUDA in a usable way (coding any ML directly in CUDA is a death sentence to deadlines), which leaves python $\endgroup$ – Recessive Jan 30 at 5:41
1
$\begingroup$

I think the best explanation is the Pareto Principle, where in this case, 80% of the the performance comes from 20% of the code. Most machine learning frameworks have a Python API that developers use, but the internals are usually implemented using C++ or CUDA (for GPU acceleration) or using specialized libraries like BLAS. This latter component is the 20% producing 80% of the performance, while the remaining 80% is python code that has a minimum effect on performance.

The internals in C++/CUDA are the ones that produce most of the good performance of these libraries (this is specially true for TensorFlow and PyTorch), as they have or use internal specialized libraries to do heavy computation, the best example of this is cuDNN, cuBLAS, etc.

And in the end you do not actually need a C++ developer to make neural networks and machine learning models, python is a flexible language, with great library (numpy, scikit-learn, pandas, etc) and community support, so in python you can quickly make prototype networks and train them in multiple GPUs or on a distributed environment, and it runs quite fast.

If you develop a product that will use a machine learning model in an embedded system, you might need a low level C++ developer to make the most efficient implementation of the ML model, but this is also a very specialized job that not many people can do. A good python ML researcher can produce a well tuned model and only later the device implementation and optimization can really be done.

Also do not forget that C++ is not an easy language, mastering it might take longer than the current Deep Learning field has existed (> 5 years).

| improve this answer | |
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.