Torch7: Installing from luarocks fails with `torchcwrap not found`

Created on 1 Jun 2015  路  14Comments  路  Source: torch/torch7

/home/user/torch/install/bin/luajit: /tmp/luarocks_torch-scm-1-8328/torch7/random.lua:3: module 'torchcwrap' not found:
    no field package.preload['torchcwrap']
    no file '/home/user/.luarocks/share/lua/5.1/torchcwrap.lua'
    no file '/home/user/.luarocks/share/lua/5.1/torchcwrap/init.lua'
    no file '/usr/local/share/lua/5.1/torchcwrap.lua'
    no file '/home/user/git/luarocks/src/torchcwrap.lua'
    no file '/home/user/.luarocks/lib/lua/5.1/torchcwrap.so'
    no file './torchcwrap.so'
    no file '/usr/local/lib/lua/5.1/torchcwrap.so'
    no file '/usr/lib/x86_64-linux-gnu/lua/5.1/torchcwrap.so'
    no file '/usr/lib/lua/5.1/torchcwrap.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
    [C]: in function 'require'
    /tmp/luarocks_torch-scm-1-8328/torch7/random.lua:3: in main chunk
    [C]: at 0x00406670
make[2]: *** [random.c] Error 1
make[1]: *** [CMakeFiles/torch.dir/all] Error 2
make: *** [all] Error 2

Seems that torchcwrap.lua is in the same directory as random.lua, but for some reason not imported ok by random.lua.

Most helpful comment

Necromancer alert. Maybe this is of use: I had exactly the same issue (user of Mac ports). Magically, using sudo ./install.sh fixed it.

All 14 comments

this is again, afaik, a false-positive.

there seems to be something really strange with your luarocks.

I just tested this, and seems to work.

How can I reproduce this on my end?

is this the luarocks that is shipped (sorry for asking again). And also, thanks a lot for the feedback.

Something like this:

`````` bash

!/bin/bash

build luarocks, from git:

cd $HOME
mkdir git
cd git
git clone https://github.com/keplerproject/luarocks.git

cd luarocks
./configure
make -j 4 build

echo '#!/bin/bash'>setenv.sh
echo 'PATH=$PATH:$HOME/git/luarocks/src/bin'>>setenv.sh
echo 'eval $(luarocks path --bin)'>>setenv.sh
source setenv.sh

create luarocks config file:

mkdir ~/.luarocks
echo "rocks_trees = {'/home/user/.luarocks'}">~/.luarocks/config-5.1.lua
echo "rocks_servers = {'http://luarocks.org/repositories/rocks'}">> ~/.luarocks/config-5.1.lua

cat /etc/lsb-release

DISTRIB_ID=Ubuntu

DISTRIB_RELEASE=14.04

DISTRIB_CODENAME=trusty

DISTRIB_DESCRIPTION="Ubuntu 14.04.2 LTS"```

``````

(I'm on the subway to work, and the torch install is a bit long, and I cant actually use torch whilst it's running :-P I'll try to come up with something more complete later on; feel free to just ignore this for now :-) )

I'll look at this anothre time ;-) Closing it for now.

Ok, so....

  • I reinstalled luarocks, by adding --prefix /opt/luarocks to the configure, and actually doing make install and now the compile works ok :-)
  • I did however need to modify my ~/torch/activate slightly, in order to be able to do require 'torch', by adding eval $(luarocks path --bin) to the end of ~/torch/activate:
#!/bin/bash

export PATH=/home/user/torch/install/bin:$PATH
export LD_LIBRARY_PATH=/home/user/torch/install/lib:$LD_LIBRARY_PATH 
export DYLD_LIBRARY_PATH=/home/user/torch/install/lib:$DYLD_LIBRARY_PATH 

eval $(luarocks path --bin)

Not sure if this is necessary/useful, or whether it's just another artefact of my eschewing installing into global system directories.

Necromancer alert. Maybe this is of use: I had exactly the same issue (user of Mac ports). Magically, using sudo ./install.sh fixed it.

nuance/caveat: using sudo for installtion is often one-way: after using it once, many intsalled files are now owned by root, and then normal, non-sudo, intsallation becomes impossible without first removing/chowning those files. (so, I would personally want to be really sure I've exhausted all avenues before going the sudo route)

I have been quite exhausted indeed after wasting a few hours on this. I'll probably send in a mac-ports PR inside install-deps, as the automagic Homebrew hurts my system. Note that mac-ports always uses sudo, whereas afaik Homebrew doesn't. I ofc do agree with your recommendation.

ah, I have dabbled with brew on linux, and found it resembled what people used to say on slashdot about gentoo: took hours/days just to do what apt-get could do in a few minutes :-P Is mac-ports more like apt-get, ie intsalls binaries, rather than building them all from scratch?

Scratch. apt-get is vastly superior. But Mac is vastly more hip.
But the scratch has advantages. f.e. if I want to install opencv with intel tbb and opencl support i just say port install opencv +tbb +ocl and it builds with tbb and opencl support.

Ok... well... ok...

I guess if you're using sudo to build everything from source in mac-ports, then using sudo to build torch from scratch kind of fits into that philosophy.

Leaving this here in case it's helpful to others:

sudo chmod -R 777 . from the torch git repo directory fixed this issue for me. Unclear whether this is actually any less dirty than using sudo to install.

is there any solution without using sudo?

@bill2239 @juesato
Please check if you set environment variable like LUA_PATH, LUA_CPATH. I noticed that in my case and @hughperkins case, there are messages like
no file '/home/user/.luarocks/share/lua/5.1/torchcwrap.lua'.

So why check those paths? I found LUA_PATH and LUA_CPATH in my bashrc. After comment out those lines, everything works fine.

Please have a try.

Was this page helpful?
0 / 5 - 0 ratings