Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using torch for a c++ executable (NDK) #66

Open
kk291 opened this issue Jun 23, 2016 · 5 comments
Open

Using torch for a c++ executable (NDK) #66

kk291 opened this issue Jun 23, 2016 · 5 comments

Comments

@kk291
Copy link

kk291 commented Jun 23, 2016

Hi,

I am trying to write c++ code (making use of torch) and build an executable using NDK. Not sure how to go about this. Has anyone got it working? Please help.

@borisfom
Copy link
Collaborator

That may be more pain that is needed. Demo example shows how to use Java wrapper. All you need to add is the way to feed your scripts into Torch.
Also, NDK wont give you CUDA, you need to use NVidia CodeWorks for that.

@kk291
Copy link
Author

kk291 commented Jun 24, 2016

Cant I use it without CUDA? I had built torch-android with WITH_CUDA=OFF. While trying to build the android-demo, I was getting the prints like "libs THCUNN and cutorch not found". Upon removing them from the makefile(jni/Android.mk), I was able to build the demo. But, the app torch-demo does not run properly on my device. I get the prints"loader_android:name=cutorch failed". What must be done ?

@borisfom
Copy link
Collaborator

Sure you can; you should remove cutorch references from demo. it's just the performance is going to suck.

@kk291
Copy link
Author

kk291 commented Jun 24, 2016

I will try that .. Yes .. I am expecting the performance to be worser .. I am trying to use only the CPU for my execution .. If I write a sample lua file and try to feed it to Torch and if the sample file has code like "require image", it means the file libimage.so is needed right? Should the .so be present in a particular location or directory? I have tried using the code similar to the one used here: #62
I get the error "PANIC: unprotected error in call to Lua API (attempt to call a nil value)" when I have "require image" in my lua script. I have placed the file libimage.so and the lua script in the same location.
What might be the problem.

Edit:: I see in the code that the contents of assets folder are being used for loading. Does it take care of "require image" ?. I am trying to figure out how to use it without going through AssetManager.

@borisfom
Copy link
Collaborator

You need to load libimage.so and libpng.so explicitly from Java, see the example in demo app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants