# Model move from python to ios missing lapack

**URL:** <https://discuss.pytorch.org/t/model-move-from-python-to-ios-missing-lapack/135317>\
**Category:** Mobile\
**Created:** [October 28, 2021, 11:16am UTC](https://discuss.pytorch.org/t/model-move-from-python-to-ios-missing-lapack/135317 "2021-10-28T11:16:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/matt_davis/32/43394_2.png) [@Matt\_Davis](https://discuss.pytorch.org/u/Matt_Davis)\
**Post date:** [October 28, 2021, 11:16am UTC](https://discuss.pytorch.org/t/model-move-from-python-to-ios-missing-lapack/135317/1 "2021-10-28T11:16:34Z")

</div>

Ok, I have a model that I am trying to move to ios.

I figured out most of the jit export commands. After running the model on mobile it is saying missing the lapack. I read a few others forums on here that you have to build with la pack. My question is do I build the local pytorch doing the training and export or do I rebuild the libtorch for ios?

I think I need to rebuild torch, load up my models and jit save them there after. Is that the correct flow?

---

<div class="post-metadata">

**Author:** ![kimishpatel](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/kimishpatel/32/39320_2.png) [@kimishpatel](https://discuss.pytorch.org/u/kimishpatel)\
**Post date:** [October 28, 2021, 1:59pm UTC](https://discuss.pytorch.org/t/model-move-from-python-to-ios-missing-lapack/135317/2 "2021-10-28T13:59:08Z")

</div>

I think you need to rebuild libtorch for ios with LAPACK. @xta0 if he has more input.

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/matt_davis/32/43394_2.png) [@Matt\_Davis](https://discuss.pytorch.org/u/Matt_Davis)\
**Post date:** [October 28, 2021, 5:27pm UTC](https://discuss.pytorch.org/t/model-move-from-python-to-ios-missing-lapack/135317/3 "2021-10-28T17:27:13Z")

</div>

Ok thanks. I was following you other tutorial from this thread on mobile: [LAPACK library not found in compilation (Pytorch Mobile, Android, Java) - #10 by Paran0](https://discuss.pytorch.org/t/lapack-library-not-found-in-compilation-pytorch-mobile-android-java/126849/10)  
you noted the changed on torch for the libtorch solution I think?  
I’ll try followinrg the [iOS | PyTorch](https://pytorch.org/mobile/ios/#build-pytorch-ios-libraries-from-source)

This turned moving a model from a few hour task to days to weeks, would love this included 🙂

---

<div class="post-metadata">

**Author:** ![kimishpatel](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/kimishpatel/32/39320_2.png) [@kimishpatel](https://discuss.pytorch.org/u/kimishpatel)\
**Post date:** [October 29, 2021, 2:51pm UTC](https://discuss.pytorch.org/t/model-move-from-python-to-ios-missing-lapack/135317/4 "2021-10-29T14:51:07Z")

</div>

Yeah I had forgotten about what I wrote on that thread :). But it sounds about right. Unfortunately it may require some manual tweaking and building pt from source. I think we will try to include lapack in pt mobile builds for future. Do you mind filing an issue and tagging me on it? Thanks!

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/matt_davis/32/43394_2.png) [@Matt\_Davis](https://discuss.pytorch.org/u/Matt_Davis)\
**Post date:** [October 31, 2021, 7:45pm UTC](https://discuss.pytorch.org/t/model-move-from-python-to-ios-missing-lapack/135317/6 "2021-10-31T19:45:31Z")

</div>

Ok, sent a github issue:

> <https://github.com/pytorch/pytorch/issues/67599>
>
> \## 🚀 Feature
> 
> Include lapackage in the libtorch and pytorch builds so that jit… exports utilizing these packages do not require custom builds in order for the jit exports to work. 
> 
> \## Motivation
> 
> 
> Trying to get a model moved over to mobile has grown to a much bigger task when I have to rebuild torch or libtorch, I'm not sure which I have to rebuild in order to move the model to mobile. Other then that moving to mobile in pytorch I have found incredibly easy. 
> 
> \## Pitch
> 
> 
> Change the build ios cmake args to use lapack 
> Change the cmake on pytorch to in the devdependencies to have use lapack turned to 1 
> 
> \## Alternatives
> 
> 
> 
> \## Additional context
> 
> 
> https://discuss.pytorch.org/t/model-move-from-python-to-ios-missing-lapack/135317/4

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/matt_davis/32/43394_2.png) [@Matt\_Davis](https://discuss.pytorch.org/u/Matt_Davis)\
**Post date:** [November 7, 2021, 10:43pm UTC](https://discuss.pytorch.org/t/model-move-from-python-to-ios-missing-lapack/135317/7 "2021-11-07T22:43:12Z")

</div>

Tried to put the pytroch model exported on the device and it says the model version is 7 and software is 2 - 5 supported. Is that cause I need to rebuild and use libtorch now?

---

<div class="post-metadata">

**Author:** ![kimishpatel](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/kimishpatel/32/39320_2.png) [@kimishpatel](https://discuss.pytorch.org/u/kimishpatel)\
**Post date:** [November 9, 2021, 3:35pm UTC](https://discuss.pytorch.org/t/model-move-from-python-to-ios-missing-lapack/135317/8 "2021-11-09T15:35:58Z")

</div>

Yeah so you probably exported model using later versions of libtorch but the libtorch/runtime on the device is older one. So it is likely backwards compatibility (newer models cannot run on older runtime) issue. You will have to update the runtime on device. Alternatively we have backporting supported but I dont remember since when. Which version of libtorch you are using? Or are you building from source?

@Martin_Yuan for more info on backporting.

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/matt_davis/32/43394_2.png) [@Matt\_Davis](https://discuss.pytorch.org/u/Matt_Davis)\
**Post date:** [November 14, 2021, 1:31pm UTC](https://discuss.pytorch.org/t/model-move-from-python-to-ios-missing-lapack/135317/9 "2021-11-14T13:31:14Z")

</div>

Using the latest ios cocoapod but I had to rebuild pytorch for the la pack so I assume the libtorch needs to be rebuilt right?

---

<div class="post-metadata">

**Author:** ![kimishpatel](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/kimishpatel/32/39320_2.png) [@kimishpatel](https://discuss.pytorch.org/u/kimishpatel)\
**Post date:** [November 15, 2021, 3:44pm UTC](https://discuss.pytorch.org/t/model-move-from-python-to-ios-missing-lapack/135317/10 "2021-11-15T15:44:23Z")

</div>

I think so. Let us know if rebuilding from source does not work for you.
