I install all torch package into my local file torch-distro(Followed by this tutorial). I want to use Zerobrane to debug my code. Zerobrane can't find my local path of torch. How Can I set my local path to the Zerobrane environment variable.
I tried to add path.lua = "${prefix}/torch-distro/install/bin/luajit" into the user.lua. But it can't work
- 5,977
- 14
- 55
- 77
-
On which OS are you? On Ubuntu 14.04 [this](http://studio.zerobrane.com/doc-remote-debugging.html) works just fine. – Atcold Oct 20 '14 at 19:15
2 Answers
Following method works on linux platform:
Configuring the luajit interpreter by adding following code into the user.lua
path.lua = "your_path/luajit"Configuring the envrioment variable by adding following code into the /opt/zbsstudio/lualibs/mobdebug/mobdebug.lua
package.path = package.path .. ';my_path/?/init.lua' package.cpath = package.cpath .. ';my_path/?.so'
- 5,977
- 14
- 55
- 77
(These instructions are for the Windows version of Torch, but the steps should work for Linux/OSX versions assuming the paths are modified).
Let's say the Torch is installed in C:\Program Files\Torch, then to get it running as the external interpreter from ZeroBrane Studio (ZBS), you need to add path.lua=[[C:\Program Files\Torch\bin\torch-lua]] to <ZBS>\cfg\user.lua configuration file.
Now, when you execute a Lua script from ZBS (Project | Run or F6), it will run inside the Torch environment:
local torch = require 'torch'
local data = torch.Tensor{
{68, 24, 20},
{74, 26, 21},
{80, 32, 24}
}
print(data)
However, there are few more steps required to get the debugging to work on Windows (these steps are likely not be needed on other systems, but I haven't tested debugging there). ZBS is using luasocket, which is compiled against lua51.dll, but Torch is using libtorch-lua.dll, so loading luasocket into your (Torch) process is likely to crash it. To make it work, you need to build a proxy DLL and put it into your Torch/bin folder.
To build the proxy DLL, you will need Visual Studio C++ or mingw/gcc compiled and can follow these steps:
- Get
mkforwardlib.lua(VS) ormkforwardlib-gcc.lua(mingw/gcc) script from Lua Proxy DLL3 page. - Run
lua mkforwardlib.lua libtorch-lua lua51 X86; if everything goes well, this will producelua51.dllfile in the current folder. - Copy
lua51.dllfile toTorch\binfolder.
Now you should be able to debug Torch scripts by using Project | Start Debugging.
- 25,884
- 3
- 38
- 56