r/pytorch • • Sep 21 '20

Pytorch support for Julia

I am curious if Pytorch would support for Julia as like C++.

As all other, I also personally found c++ as jibrish, instead Julia which is as fast as c and as pythonic as python.

I would like to see if it happens in future.

0 Upvotes

7 comments sorted by

3

u/MrAcurite Sep 21 '20

Is Julia really that much faster than Python though? I mean, what would you really be doing with it where you'd see a tangible benefit over Python, that outweighs the existing package support Python has?

2

u/snailzrus Sep 21 '20

I mean you can look up articles on it, put to summarize, Julia absolutely slaughters python in speed. The only way python currently competes in speed is to use a library called cython which will allow you to compile your python code as C, but even C isn't as fast as Julia. Here's a link to a well written article: https://theiotmagazine.com/julia-vs-python-will-it-unseat-the-king-of-programming-8220e4cd2e0a

To bring the topic back to ML, python wasn't built for ML, but rather it adapted to it. Julia on the other hand was built with ML in mind and was optimized for it from the start. I don't know how the comparison between python and Julia stands once GPUs come into play, but I'd gamble to say Julia would be faster in deployment while python would be faster in development based on the fact that you'd need to compile Julia but not python.

5

u/MrAcurite Sep 21 '20

Yes, but consider that using Python for ML is primarily using Python to call C/C++ CUDA bindings. The only speed differences would be the relatively minute overhead.

0

u/louistoot Sep 21 '20

If you want to build custom layers, for example, you need to implement them in c++ when using PyTorch if performance matters. I had this problem with a custom LSTM cell, you cannot make it as fast as the highly optimized c++ layers. In Julia, you could actually write the same layer in plain Julia with similar performance as c++.

1

u/MrAcurite Sep 21 '20

Touche, I suppose. Still, with Python, most of the work would still be on the GPU in C++, but I could see it adding up quickly in that case.

2

u/haruishi Sep 21 '20

Are there many people wanting to use Pytorch on Julia? Julia has flux and some people made bindings for pytorch but I don’t see the popularity for Julia interface yet

1

u/chatterbox272 Sep 22 '20

Unlikely, the only strong pitch is that it may be easier to write low-level CUDA kernels rather than writing CUDA code directly, in which case we need CUDA.jl to be compilable to the same binary as we get from normal CUDA code and nvcc. The other parts of the pipeline are either fine in Python, or sufficiently served with TorchScript