# \[support\] Pytorch for Julia

**URL:** <https://discourse.julialang.org/t/support-pytorch-for-julia/46211>\
**Category:** General Usage\
**Created:** [September 7, 2020, 5:47pm UTC](https://discourse.julialang.org/t/support-pytorch-for-julia/46211 "2020-09-07T17:47:07Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![newtojulia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/newtojulia/32/17754_2.png) [@newtojulia](https://discourse.julialang.org/u/newtojulia)\
**Post date:** [September 7, 2020, 5:47pm UTC](https://discourse.julialang.org/t/support-pytorch-for-julia/46211/1 "2020-09-07T17:47:08Z")

</div>

Is there any Pytorch framework in Julia.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [September 7, 2020, 6:08pm UTC](https://discourse.julialang.org/t/support-pytorch-for-julia/46211/2 "2020-09-07T18:08:32Z")

</div>

[https://github.com/FluxML/Torch.jl](https://github.com/FluxML/Torch.jl)

You can also just use

[https://github.com/JuliaPy/PyCall.jl](https://github.com/JuliaPy/PyCall.jl)

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [September 7, 2020, 6:18pm UTC](https://discourse.julialang.org/t/support-pytorch-for-julia/46211/3 "2020-09-07T18:18:34Z")

</div>

What were you planning on using Torch for? There might be Julia alternatives as well, such as Flux (deep learning) or Zygote (AD)

---

<div class="post-metadata">

**Author:** ![newtojulia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/newtojulia/32/17754_2.png) [@newtojulia](https://discourse.julialang.org/u/newtojulia)\
**Post date:** [September 7, 2020, 6:30pm UTC](https://discourse.julialang.org/t/support-pytorch-for-julia/46211/4 "2020-09-07T18:30:07Z")

</div>

@baggepinnen, thanks but i want to use just Pytorch, because i am unfamlier to other

---

<div class="post-metadata">

**Author:** ![orialb](https://avatars.discourse-cdn.com/v4/letter/o/65b543/32.png) [@orialb](https://discourse.julialang.org/u/orialb)\
**Post date:** [September 7, 2020, 7:39pm UTC](https://discourse.julialang.org/t/support-pytorch-for-julia/46211/5 "2020-09-07T19:39:32Z")

</div>

I think it is still important to know what is your intended use case in order for people to give you some advice. For example do you want to interface with some other Julia packages or just want to do standard DL?  
If you have a strong wish to use just pytorch, why not just use pytorch directly from python?

---

<div class="post-metadata">

**Author:** ![newtojulia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/newtojulia/32/17754_2.png) [@newtojulia](https://discourse.julialang.org/u/newtojulia)\
**Post date:** [September 8, 2020, 2:31am UTC](https://discourse.julialang.org/t/support-pytorch-for-julia/46211/6 "2020-09-08T02:31:12Z")

</div>

why not use Pytorch from julia?

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [September 8, 2020, 2:47am UTC](https://discourse.julialang.org/t/support-pytorch-for-julia/46211/7 "2020-09-08T02:47:28Z")

</div>

Unfortunately, this is more of a philosophical question that doesn’t have one single answer. To keep this conversation going, I would _strongly_ recommend that you describe more about your use-case, both in terms of what you want to use an ML framework like PyTorch for and where/why you’re looking to use Julia. “Why not?” doesn’t give us anything to work with 🙂.

---

<div class="post-metadata">

**Author:** ![newtojulia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/newtojulia/32/17754_2.png) [@newtojulia](https://discourse.julialang.org/u/newtojulia)\
**Post date:** [September 8, 2020, 2:49am UTC](https://discourse.julialang.org/t/support-pytorch-for-julia/46211/8 "2020-09-08T02:49:57Z")

</div>

As fast programming language, I wanted to use Julia instead of other 🙂 .

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [September 8, 2020, 2:58am UTC](https://discourse.julialang.org/t/support-pytorch-for-julia/46211/9 "2020-09-08T02:58:37Z")

</div>

If you’re using Torch.jl, it just issues calls to PyTorch, which’ll be no faster than just using Torch directly. Julia’s speed is only gained within Julia itself - it’s not a magic wand capable of speeding up external libraries.

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [September 8, 2020, 3:05am UTC](https://discourse.julialang.org/t/support-pytorch-for-julia/46211/10 "2020-09-08T03:05:41Z")

</div>

Sorry, I should have been more precise: what is the problem you’re trying to solve (e.g. identifying [hot dogs vs non hot dogs](https://apps.apple.com/us/app/not-hotdog/id1212457521)) and what algorithms/methods are you planning to solve it with (e.g. resnet50 or some other deep computer vision model)? Some example code, papers and/or GitHub repos would help here.

I ask because Julia (at least currently) will _not_ make your deep learning code faster unless you are working with some very specific algorithms. As @stillyslalom and others have mentioned, using Torch.jl or calling PyTorch from Julia using PyCall should not perform better than just using PyTorch from Python.

---

<div class="post-metadata">

**Author:** ![ks20](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ks20/32/31155_2.png) [@ks20](https://discourse.julialang.org/u/ks20)\
**Post date:** [November 27, 2021, 11:18am UTC](https://discourse.julialang.org/t/support-pytorch-for-julia/46211/11 "2021-11-27T11:18:27Z")

</div>

Hello

An expansion to the original question- can I use julia to do the heavy lifting (large nested loops for instance) and let pytorch handle the rest. My specific use case being nlp classification using skip grams, how do I use julia to run parts which involves calculation of losses, and accuracies - all of which use pytorch modules. In other words, I want julia to run a loop which calls a pytorch model and peform some analysis after that.  
I’m working with Jupyter notebooks and searching for ways to integrate julia and python didn’t help much.

Would be great if someone share similar experiences or anything useful.

Cheers & thanks in advance.
