# Can I import torch on PYNQ?

**URL:** <https://discuss.pynq.io/t/can-i-import-torch-on-pynq/1540>\
**Category:** Support\
**Created:** [July 22, 2020, 4:11am UTC](https://discuss.pynq.io/t/can-i-import-torch-on-pynq/1540 "2020-07-22T04:11:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![B1D1ng](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/b1d1ng/32/1108_2.png) [@B1D1ng](https://discuss.pynq.io/u/B1D1ng)\
**Post date:** [July 22, 2020, 4:11am UTC](https://discuss.pynq.io/t/can-i-import-torch-on-pynq/1540/1 "2020-07-22T04:11:05Z")

</div>

Can I import the pytorch framework package on PYNQ ?

---

<div class="post-metadata">

**Author:** ![Noah\_Keller](https://avatars.discourse-cdn.com/v4/letter/n/9de0a6/32.png) [@Noah\_Keller](https://discuss.pynq.io/u/Noah_Keller)\
**Post date:** [July 22, 2020, 8:37am UTC](https://discuss.pynq.io/t/can-i-import-torch-on-pynq/1540/2 "2020-07-22T08:37:35Z")

</div>

Hey @B1D1ng from reading this [post](https://discuss.pynq.io/t/a-no-cross-compile-of-pytorch-and-opencv-using-aws-a1-instances/717) under the section results. The author mentions that building the PyTorch Framework on a Ulrta96 Board never finishes.

There is another approach in this [post](https://discuss.pynq.io/t/pynq-torch-a-framework-to-develop-pytorch-accelerators-on-the-pynq-platform/669). I didn’t try out either of both approaches. It just happens that I wanted to try out the same thing and was reading through the posts. So if you have any results, it would be nice if you share it here 😄

---

<div class="post-metadata">

**Author:** ![B1D1ng](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/b1d1ng/32/1108_2.png) [@B1D1ng](https://discuss.pynq.io/u/B1D1ng)\
**Post date:** [July 22, 2020, 4:13pm UTC](https://discuss.pynq.io/t/can-i-import-torch-on-pynq/1540/3 "2020-07-22T16:13:07Z")

</div>

Thanks for your reply!! Have you ever used the QNN-MO-PYNQ?([GitHub - Xilinx/QNN-MO-PYNQ](https://github.com/Xilinx/QNN-MO-PYNQ)) I do not know how can this model detect new targets like smoke, helmet etc.  
On the Pytorch-Yolov3 I can train my custom dataset and finally detect the new target. QNN-MO-PYNQ’s author seems do not tell something about that.

---

<div class="post-metadata">

**Author:** ![Noah\_Keller](https://avatars.discourse-cdn.com/v4/letter/n/9de0a6/32.png) [@Noah\_Keller](https://discuss.pynq.io/u/Noah_Keller)\
**Post date:** [July 22, 2020, 5:10pm UTC](https://discuss.pynq.io/t/can-i-import-torch-on-pynq/1540/4 "2020-07-22T17:10:29Z")

</div>

I’ve looked into the GitHub Site and saw that they’ve used the [FINN Framework](https://xilinx.github.io/finn/) with the HLS workflow. But I’ve never used it before I am sorry. I would probably create a new post for further instructions.

Might be interesting for you to try to compile your model for the [DPU](https://github.com/Xilinx/DPU-PYNQ) since PYNQ now supports Xilinx DPU IP. The DPU workflow seems to be easier than the FINN workflow.

---

<div class="post-metadata">

**Author:** ![B1D1ng](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/b1d1ng/32/1108_2.png) [@B1D1ng](https://discuss.pynq.io/u/B1D1ng)\
**Post date:** [July 22, 2020, 5:35pm UTC](https://discuss.pynq.io/t/can-i-import-torch-on-pynq/1540/5 "2020-07-22T17:35:09Z")

</div>

thank u very much!  
I searched DPU-PYNQ and found that it supports the Yolov3 model and can even be trained and tested. Is the Yolov3 model reproduced in this project? Do I only need to provide the dataset for training?

---

<div class="post-metadata">

**Author:** ![Noah\_Keller](https://avatars.discourse-cdn.com/v4/letter/n/9de0a6/32.png) [@Noah\_Keller](https://discuss.pynq.io/u/Noah_Keller)\
**Post date:** [July 23, 2020, 1:56pm UTC](https://discuss.pynq.io/t/can-i-import-torch-on-pynq/1540/6 "2020-07-23T13:56:06Z")

</div>

If you want to train your own models, I would recommend to follow this [instructions](https://github.com/Xilinx/DPU-PYNQ/tree/master/host). They show an example how to train and compile a model with the MNIST data set for the DPU.

---

<div class="post-metadata">

**Author:** ![B1D1ng](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/b1d1ng/32/1108_2.png) [@B1D1ng](https://discuss.pynq.io/u/B1D1ng)\
**Post date:** [July 23, 2020, 2:15pm UTC](https://discuss.pynq.io/t/can-i-import-torch-on-pynq/1540/7 "2020-07-23T14:15:14Z")

</div>

Thanks for your reply!  
The MNIST data set is for numbers, but my data set is a picture data set. I plan to deploy the target detection model to the PYNQ-Z2 board. After deployment, the performance of the model is temporarily ignored, as long as it can be successfully deployed .  
I understand that the PYNQ-Z2 board can also support DPU. Does this mean that I can quantify and compile deep learning models such as Tensorflow-yolov3 and deploy them on the PYNQ-Z2 board? Even if the board performance is not particularly suitable.  
Looking forward to your reply! Thank you very much !

---

<div class="post-metadata">

**Author:** ![Noah\_Keller](https://avatars.discourse-cdn.com/v4/letter/n/9de0a6/32.png) [@Noah\_Keller](https://discuss.pynq.io/u/Noah_Keller)\
**Post date:** [July 23, 2020, 2:42pm UTC](https://discuss.pynq.io/t/can-i-import-torch-on-pynq/1540/8 "2020-07-23T14:42:07Z")

</div>

for the answer: " Does this mean that I can quantify and compile deep learning models such as Tensorflow-yolov3 and deploy them on the PYNQ-Z2 board? "

I think so, but unfortunately I didn’t try it out myself.  
I am not sure if the DPU supports the PYNQ-Z2. Probably somebody else on the forum tried it out before.

Probably it is better to reformulate the question and try to get somebody who is more knowledgeable than me. 😉

---

<div class="post-metadata">

**Author:** ![B1D1ng](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/b1d1ng/32/1108_2.png) [@B1D1ng](https://discuss.pynq.io/u/B1D1ng)\
**Post date:** [July 23, 2020, 2:54pm UTC](https://discuss.pynq.io/t/can-i-import-torch-on-pynq/1540/9 "2020-07-23T14:54:06Z")

</div>

OK, anyway, thank u so much! Have a good day!!

---

<div class="post-metadata">

**Author:** ![manoharvhr](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/manoharvhr/32/445_2.png) [@manoharvhr](https://discuss.pynq.io/u/manoharvhr)\
**Post date:** [July 24, 2020, 8:12am UTC](https://discuss.pynq.io/t/can-i-import-torch-on-pynq/1540/10 "2020-07-24T08:12:04Z")

</div>

Hey, have you tried the instructions on the PYNQ-Torch work?
