3

I'm trying to use openresty with torch for a Rest api for a neural network. First query works, any query after that fails.

Nginx Config

workers processes 1;

error_log logs/error.log;
events {
    workers connections 1024
}
http {
    server {
        listen 5050;
        location /{
            default type text/html;
            content_by_lua_file /home/yiftach/testFile.lua;
        } 
    } 
}

testFile.lua

require "nn" 
local tensorA=torch.zeros(1,1)
ngx.say(tensorA:size()[1])

The error:

Lua entry thread aborted: runtime error: /home/yiftach/testFile.lua: attempt to index global 'torch' (a nil value)

Would appreciate any help

2
  • require 'torch'? I don't see any usage of nn package Commented Jun 18, 2015 at 21:00
  • there is no 'torch' package, nn includes the torch object Commented Jun 20, 2015 at 8:34

1 Answer 1

1

You didn't require the torch library. Add local torch = require "torch" at the top.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.