Model Loading issue in iOS

I get the following error when trying to initialize a traced model with the iOS framework:
PyTorchDemo[25132:6735005] false CHECK FAILED at /Users/distiller/project/c10/core/Backend.h (tensorTypeIdToBackend at /Users/distiller/project/c10/core/Backend.h:106)
(no backtrace available)

The error appears similar to these Android issues:


The second linked issue states that there’s an Android update with a fix --is there a fix for the iOS framework?

The model I’m using was traced with PyTorch 1.3.1, and I’m using LibTorch 1.3.1

Looks like the fix was landed to master as mentioned on #29806 so it will be part of 1.4 release. You can test the nightly build of iOS. @IvanKobzarev could you please confirm?

Yeah, I’m pretty sure this is resolved. If you want to verify, the steps for testing with the nightly build are in the first half of this comment: Incomprehensible behaviour

Hi @kennywalker, are you using cocoapods on iOS? if so, the correct version should be 1.3.1. If the error still exist, try the iOS nightly build - https://ossci-ios-build.s3.amazonaws.com/libtorch_ios_nightly_build.zip. Let me know if you have any questions.

The model loads with the nightly build.

Thank you for the help @ljk53, @David_Reiss, @xta0

1 Like

Hi @xta0

I was using cocoapods 1.3.1. Can the 1.4 podspec be published?.

Hi @kennywalker, we’re going to publish 1.4 in Jan (Hopefully). Could you give a solution mark on this? If there is any questions, feel free to leave a comment.

Hi @xta0, is there an update about the release date of 1.4 for iOS?

I think it’ll be in the middle of Jan. @jspisak do you know the exact date?

Yes, we are targeting mid next week to release 1.4. Look for the blog post on pytorch.org. :slight_smile:

Dear @xta0, I tried to use the current iOS nightly build, but it doesn’t work. I’ve noticed that the file libtorch.a has only 944 bytes.

Dear @kennywalker, could you share with us the version you downloaded on December 19th, please?

@fabricionarcizo the nightly build is from master branch. We’ve recently split the libtorch.a into multiple libraries. If you unzip the nightly build, you should see this - libtorch_cpu.a which is the old libtorch.a.

@xta0 I just tried to compile the libtorch.a using the branch v1.4.0 with the following command:

SELECTED_OP_LIST=predictor.yaml BUILD_PYTORCH_MOBILE=1 IOS_ARCH=arm64 ./scripts/build_ios.sh

It compiles correctly, but I got some additional error when I try to link the libtorch.a on Xcode.

Undefined symbol: c10::NonVariableTypeMode::is_enabled()
Undefined symbol: torch::jit::script::Module::module_object() const
Undefined symbol: c10::NonVariableTypeMode::set_enabled(bool)
Undefined symbol: caffe2::detail::_typeMetaDataInstance_preallocated_6
Undefined symbol: at::TypeDefault::to(at::Tensor const&, c10::TensorOptions const&, bool, bool)

@fabricionarcizo SELECTED_OP_LIST is used for the custom build. Also, the build is in arm64, were you running in simulator?

Since I don’t have your code, my recommendation is to follow the tutorials