在 iTorch 中使用 nn 包

当我在 iTorch 中运行需要 require nn 的代码时,我在 Jupyter 中会遇到以下错误:

[string "require 'nn'..."]:1: module 'nn' not found:
no field package.preload['nn']
no file '/usr/local/share/lua/5.2/nn.lua'
no file '/usr/local/share/lua/5.2/nn/init.lua'
no file '/usr/local/lib/lua/5.2/nn.lua'
no file '/usr/local/lib/lua/5.2/nn/init.lua'
no file './nn.lua'
no file '/usr/local/lib/lua/5.2/nn.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './nn.so'
stack traceback:
/usr/local/share/lua/5.2/itorch/main.lua:166: in function        </usr/local/share/lua/5.2/itorch/main.lua:159>
[C]: in function 'require'
[string "require 'nn'..."]:1: in main chunk
[C]: in function 'xpcall'
/usr/local/share/lua/5.2/itorch/main.lua:209: in function     </usr/local/share/lua/5.2/itorch/main.lua:173>
(...tail calls...)
/usr/local/share/lua/5.2/lzmq/poller.lua:75: in function 'poll'
/usr/local/share/lua/5.2/lzmq/impl/loop.lua:307: in function 'poll'
/usr/local/share/lua/5.2/lzmq/impl/loop.lua:325: in function 'sleep_ex'
/usr/local/share/lua/5.2/lzmq/impl/loop.lua:370: in function 'start'
/usr/local/share/lua/5.2/itorch/main.lua:381: in main chunk
[C]: in function 'require'
(command line):1: in main chunk
[C]: in ?

看起来神经网络包未正确安装。使用命令 sudo luarocks install --server=http://luarocks.org/dev nn 重新安装 nn 包时,我会遇到以下错误:

Installing http://luarocks.org/dev/nn-scm-1.rockspec...
Using http://luarocks.org/dev/nn-scm-1.rockspec... switching to 'build'      mode
Cloning into 'lua-nn'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 3 (delta 0), pack-reused 0
Receiving objects: 100% (6/6), done.
Checking connectivity... done.
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/usr/local/include -c   lnn.c -o lnn.o
lnn.c:4:9: fatal error: 'nanomsg/nn.h' file not found
#include<nanomsg/nn.h>
        ^
 1 error generated.

 Error: Build error: Failed compiling object lnn.o

我该怎么解决这个问题?

点赞
用户5215440
用户5215440

在我的情况下,我使用 brew 安装了 lua,所以使用了错误的 luarocks。在使用 sudo ~/torch/install/bin/luarocks install nn 后,它可以工作。

我在这里找到了解决方案:https://groups.google.com/forum/#!msg/torch7/IRDxGaYYV9Q/u3V9XeVHOwAJ

2016-05-27 22:40:20