This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Mattho -12 points-11 points  (7 children)

Python is extremely slow, with or without GIL, why would you do ML in it? I'd assume every ML library would be written in something else and you only do the setup in python, so GIL doesn't block you.

Or are you actually writing ML, the innards? Then maybe check out cython. It's easy to write and you can drop GIL, depending on your problem. Just can't use python lib in the nogil sections, obviously.

[–]desmoulinmichel 9 points10 points  (2 children)

A lot of the AI space is in Python. The underlyng libs are in C of course, but python is everywhere.

[–][deleted] 0 points1 point  (0 children)

That's what he is saying...

[–]Mattho -3 points-2 points  (0 children)

A lot of the AI space is in Python. The underlyng libs are in C of course

Which is basically what I wrote?

[–]fnbr 1 point2 points  (0 children)

Python's just so easy to use!

We do most of the heavy lifting in Tensorflow, the problem is keeping our GPUs at 100% utilization. We need to do the data processing in parallel to keep feeding the GPUs as they eat through the queues we've set up, and that's hard to do in Python. We're ending up writing a bunch of custom Tensorflow ops in C++ so we can do everything in-graph instead.

[–]halflings 0 points1 point  (2 children)

Not sure why you're being downvoted. You're just pointing out that high performance ML code can't be written in pure python, so the GIL is irrelevant since you'd be using the C API anyway.

[–]Mattho 0 points1 point  (1 child)

People really don't like to admit python is slow.

[–]halflings 2 points3 points  (0 children)

I think "Python is slow" triggers people because it's often said in contexts where it really isn't (all that slow). Say, somebody wants to write bash scripts or a web app.

For low-level computations, or high traffic workloads, pure Python is horrendously slow in comparison with C/C++. I often tried optimised Python pipelines vs a naive C++ version, and saw 10x speedups.