torch iOS build with additional modules such as "optim" or "cvsigo"

122 views
Skip to first unread message

neubotech

unread,
Apr 1, 2016, 3:38:06 AM4/1/16
to torch7
Hi,

I'd like to build torch on iOS, so I followed the original torch iOS by Farabet https://github.com/clementfarabet/torch-ios  The example worked like a charm.

Then, I'd like to use neural networks for Openface: https://github.com/cmusatyalab/openface.  In order to use that torch, it required few more modules from lua such as "optim", "cvsigo", besides "nn".  So "nn" is included in the torch iOS example.  

I'm wondering how can I build the other modules in the "3rdparty" folder.  I've modified the script "generate_ios_framework" to include the additional modules for building the framework file, but it gave me below errors at the very end:

cp: cannot stat 'PATH to/torch-ios/build/3rdparty/optim/liboptim.a': No such file or directory

I checked the compilation, and found out that the added modules were not compiles.  This must mean that I still didn't include those as build targets in the cmake file.  But I couldn't find out where exactly I can add new building targets in the cmake files.  Do I have to configure cmake in the process, or edit additional cmake files?  It would be great if you can point me in the right direction.  

Thank you so much!


neubotech

unread,
Apr 1, 2016, 5:39:39 PM4/1/16
to torch7
Just wondering if there is any suggestions on this topic?

Adam Paszke

unread,
Apr 3, 2016, 8:53:55 AM4/3/16
to torch7
Hi, 

If you only plan on doing inference with that package, then you might not need to use optim (which contains different optimization algorithms) at all. Also, csvigo is a module for loading CSV files, so if you really need to load these, you can write a quick Lua implementation yourself (csv files are very easy to parse). You'd only need to refactor code parts that use the package.

Adam

neubotech

unread,
Apr 3, 2016, 2:40:48 PM4/3/16
to torch7
Hi Adam,

Thank you for the reply.  It is a good idea.  However, after I dig into it a little bit more, the matter seems a little more complicated than I originally asked for.

The attached openface_server.lua file is the core file to perform inferencing using Torch7.  Besides what is already available in the Torch7 iOS module, it requires the "dpnn" module.  I was curious what would happen if I ignore the "dpnn" module in the .lua file I attached, then I got below error:

/root/torch/install/bin/luajit: /root/torch/install/share/lua/5.1/torch/File.lua:343: unknown Torch class <nn.Inception>
stack traceback:
[C]: in function 'error'
/root/torch/install/share/lua/5.1/torch/File.lua:343: in function 'readObject'
/root/torch/install/share/lua/5.1/torch/File.lua:369: in function 'readObject'
/root/torch/install/share/lua/5.1/torch/File.lua:369: in function 'readObject'
/root/torch/install/share/lua/5.1/nn/Module.lua:158: in function 'read'
/root/torch/install/share/lua/5.1/torch/File.lua:351: in function 'readObject'
/root/torch/install/share/lua/5.1/torch/File.lua:409: in function 'load'
...lib/python2.7/dist-packages/openface/openface_server.lua:40: in main chunk
[C]: in function 'dofile'
/root/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: at 0x00406670

I think it indicates that the "torch.load()" function in the .lua file cannot load the pre-trained neural network model without "dpnn" module.  I took a look at the neural network model, it is saved binary.  I suspect it was created by the "dpnn" module.  This means that I can go without other modules like "optim" and "cvsigo", but running the "dpnn" module on iOS is a must.

This put me back to my original question, that "how can I make an additional cmake target so that I can compile dpnn module on iOS".  There must be a file where the original Torch iOS defined "build targets".  But I have a hard time finding it.  Do you (or anyone who is an expert) have an idea?  Thank you so much!

Nan
openface_server.lua

soumith

unread,
Apr 3, 2016, 5:17:32 PM4/3/16
to torch7 on behalf of neubotech
Hey neubiotech,

Have a look at how the optim module is referenced the build scripts, dpnn can be similarly hooked in.
torch-ios is a bit outdated, and has to be upgraded to the latest packages.

--
S

--
You received this message because you are subscribed to the Google Groups "torch7" group.
To unsubscribe from this group and stop receiving emails from it, send an email to torch7+un...@googlegroups.com.
To post to this group, send email to tor...@googlegroups.com.
Visit this group at https://groups.google.com/group/torch7.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

neubotech

unread,
Apr 3, 2016, 6:52:36 PM4/3/16
to torch7
Hi Smth,

Thanks for the reply.

Just figured out that for OpenFace port to iOS, the first thing is to build a C api for "inception" class in dpnn.  I'll try to get through this one.

On the other hand, when you mention that the "torch-ios is a bit outdated, and needs to be upgraded", are you referring to this issue about loading-pre-trained models: https://github.com/clementfarabet/torch-ios/issues/24?  What exactly needs to be upgraded, the packages or the interface for the "nn" and "nnx" module.  

I'd be willing to put in some time on both of above problems and do a pull request if you can point me to the right direction.  Thanks!

N


On Sunday, April 3, 2016 at 2:17:32 PM UTC-7, smth chntla wrote:
Hey neubiotech,

Have a look at how the optim module is referenced the build scripts, dpnn can be similarly hooked in.
torch-ios is a bit outdated, and has to be upgraded to the latest packages.

--
S
Reply all
Reply to author
Forward
0 new messages