torch / qtlua

Lua interface to QT library
Other
206 stars 73 forks source link

QTBrush:totable() a nil value #23

Open thomaspurchas opened 8 years ago

thomaspurchas commented 8 years ago

I'm trying to use the Confusion Matrix render function from Torchs optim library, however I keep getting the following message:

torch/install/share/lua/5.1/qtwidget/init.lua:82: attempt to call method 'totable' (a nil value)

I've managed to isolate a tiny chunk of code that will throw the same error:

require 'qtwidget'
paint = qt.QtLuaPainter(10,10)
brush= paint:currentbrush()
for key,value in pairs(getmetatable(brush)) do
    print("found member " .. key);
end
brush:totable()

outputting:

found member __call 
found member __index    
[string "..."]:8: attempt to call method 'totable' (a nil value)
stack traceback:
    [string "..."]:8: in main chunk
    [C]: in function 'xpcall'
    /home/r/torch/install/share/lua/5.1/itorch/main.lua:209: in function </home/r/torch/install/share/lua/5.1/itorch/main.lua:173>
    /home/r/torch/install/share/lua/5.1/lzmq/poller.lua:75: in function 'poll'
    /home/r/torch/install/share/lua/5.1/lzmq/impl/loop.lua:307: in function 'poll'
    /home/r/torch/install/share/lua/5.1/lzmq/impl/loop.lua:325: in function 'sleep_ex'
    /home/r/torch/install/share/lua/5.1/lzmq/impl/loop.lua:370: in function 'start'
    /home/r/torch/install/share/lua/5.1/itorch/main.lua:381: in main chunk
    [C]: in function 'require'
    [string "arg={'/run/user/1000/jupyter/kernel-2cfdadb3-..."]:1: in main chunk

I've checked to make sure that QT4 is install, and have tried rebuilding both qtlua and qttorch, but it's still throwing the error above.

soumith commented 8 years ago

having a look at it now. thanks for reporting.

soumith commented 8 years ago

in my install of Qt, it seems to work fine, what's your version of Qt installed, and what's your OS?

thomaspurchas commented 8 years ago

Running qmake --version and qmake-qt4 I get:

r@server1:~$ qmake --version
QMake version 3.0
Using Qt version 5.2.1 in /usr/lib/x86_64-linux-gnu
r@server1:~$ qmake-qt4 --version
QMake version 2.01a
Using Qt version 4.8.6 in /usr/lib/x86_64-linux-gnu

Running Ubuntu 14.04.3 LTS

soumith commented 8 years ago

ok, can you give the output of running the command: luarocks install qtlua

soumith commented 8 years ago

i have an ubuntu 14.04 machine as well, will try it there now.

thomaspurchas commented 8 years ago

Got a fair chunk of output from luarocks install qtlua

r@server1:~$ luarocks install qtlua
Installing https://raw.githubusercontent.com/torch/rocks/master/qtlua-scm-1.rockspec...
Using https://raw.githubusercontent.com/torch/rocks/master/qtlua-scm-1.rockspec... switching to 'build' mode
Cloning into 'qtlua'...
remote: Counting objects: 168, done.
remote: Compressing objects: 100% (163/163), done.
remote: Total 168 (delta 11), reused 122 (delta 1), pack-reused 0
Receiving objects: 100% (168/168), 362.51 KiB | 0 bytes/s, done.
Resolving deltas: 100% (11/11), done.
Checking connectivity... done.
cmake -E make_directory build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DLUA=/home/r/torch/install/bin/luajit -DLUA_BINDIR="/home/r/torch/install/bin" -DLUA_INCDIR="/home/r/torch/install/include" -DLUA_LIBDIR="/home/r/torch/install/lib" -DLUADIR="/home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lua" -DLIBDIR="/home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lib" -DCONFDIR="/home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/conf" && make

-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found
-- Found Qt4: /usr/bin/qmake-qt4 (found suitable version "4.8.6", minimum required is "4.3.0") 
-- Lua: using information from luarocks
-- Lua library guess (no info from luarocks): /home/r/torch/install/lib/libluajit.so
-- Looking for luaJIT_setmode in /home/r/torch/install/lib/libluajit.so
-- Looking for luaJIT_setmode in /home/r/torch/install/lib/libluajit.so - found
-- Lua found /home/r/torch/install/bin/luajit
-- Found readline library
-- Looking for rl_completion_matches
-- Looking for rl_completion_matches - found
-- Looking for include file fcntl.h
-- Looking for include file fcntl.h - found
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for include file signal.h
-- Looking for include file signal.h - found
-- Looking for include file unistd.h
-- Looking for include file unistd.h - found
-- Looking for include file errno.h
-- Looking for include file errno.h - found
-- Looking for include file sys/select.h
-- Looking for include file sys/select.h - found
-- Looking for include file sys/time.h
-- Looking for include file sys/time.h - found
-- Looking for include file sys/types.h
-- Looking for include file sys/types.h - found
-- Looking for isatty
-- Looking for isatty - found
-- Looking for sigprocmask
-- Looking for sigprocmask - found
-- Looking for sigaction
-- Looking for sigaction - found
-- Looking for signal
-- Looking for signal - found
-- Looking for pthread_sigmask
-- Looking for pthread_sigmask - not found
-- Looking for XInitThreads
-- Looking for XInitThreads - not found
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/luarocks_qtlua-scm-1-2061/qtlua/build
[  1%] Generating moc_qtluaengine.cxx
[  2%] Generating qtluaengine.moc
Scanning dependencies of target libqtlua
[  3%] Building CXX object qtlua/CMakeFiles/libqtlua.dir/qtluautils.cpp.o
[  4%] Building CXX object qtlua/CMakeFiles/libqtlua.dir/qtluaengine.cpp.o
[  6%] Building CXX object qtlua/CMakeFiles/libqtlua.dir/moc_qtluaengine.cxx.o
Linking CXX shared library libqtlua.so
[  6%] Built target libqtlua
[  7%] Generating moc_qluaconsole.cxx
[  8%] Generating qrc_qlua.cxx
[  9%] Generating qluaapplication.moc
[ 10%] Generating qluaconsole_unix.moc
[ 12%] Generating moc_qluaapplication.cxx
Scanning dependencies of target libqlua
[ 13%] Building CXX object qlua/CMakeFiles/libqlua.dir/qluaapplication.cpp.o
[ 14%] Building CXX object qlua/CMakeFiles/libqlua.dir/qluaconsole_unix.cpp.o
/tmp/luarocks_qtlua-scm-1-2061/qtlua/qlua/qluaconsole_unix.cpp: In member function 'void QLuaConsole::Private::command(Command)':
/tmp/luarocks_qtlua-scm-1-2061/qtlua/qlua/qluaconsole_unix.cpp:774:46: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
   (void) ::write(commandPipe[1], &command, 1);
                                              ^
[ 15%] Building CXX object qlua/CMakeFiles/libqlua.dir/moc_qluaapplication.cxx.o
[ 16%] Building CXX object qlua/CMakeFiles/libqlua.dir/qrc_qlua.cxx.o
[ 18%] Building CXX object qlua/CMakeFiles/libqlua.dir/moc_qluaconsole.cxx.o
Linking CXX shared library libqlua.so
[ 18%] Built target libqlua
Scanning dependencies of target qlua
[ 19%] Building CXX object qlua/CMakeFiles/qlua.dir/qlua.cpp.o
Linking CXX executable qlua
[ 19%] Built target qlua
[ 20%] Generating moc_qtlualistener.cxx
[ 21%] Generating qtluapainter.moc
[ 22%] Generating moc_qtluapainter.cxx
[ 24%] Generating moc_qtluaprinter.cxx
Scanning dependencies of target libqtwidget
[ 25%] Building CXX object packages/qtwidget/CMakeFiles/libqtwidget.dir/qtluapainter.cpp.o
[ 26%] Building CXX object packages/qtwidget/CMakeFiles/libqtwidget.dir/qtluaprinter.cpp.o
[ 27%] Building CXX object packages/qtwidget/CMakeFiles/libqtwidget.dir/qtlualistener.cpp.o
[ 28%] Building CXX object packages/qtwidget/CMakeFiles/libqtwidget.dir/qtwidget.cpp.o
[ 30%] Building CXX object packages/qtwidget/CMakeFiles/libqtwidget.dir/moc_qtluapainter.cxx.o
[ 31%] Building CXX object packages/qtwidget/CMakeFiles/libqtwidget.dir/moc_qtluaprinter.cxx.o
[ 32%] Building CXX object packages/qtwidget/CMakeFiles/libqtwidget.dir/moc_qtlualistener.cxx.o
Linking CXX shared module libqtwidget.so
[ 32%] Built target libqtwidget
Scanning dependencies of target libqtcore
[ 33%] Building CXX object packages/qtcore/CMakeFiles/libqtcore.dir/qtcore.cpp.o
Linking CXX shared module libqtcore.so
[ 33%] Built target libqtcore
[ 34%] Generating moc_qluamode.cxx
[ 36%] Generating qrc_qtide.cxx
[ 37%] Generating ui_qluagotodialog.h
[ 38%] Generating ui_qluafinddialog.h
[ 39%] Generating ui_qluareplacedialog.h
[ 40%] Generating qluatextedit.moc
[ 42%] Generating qluaide.moc
[ 43%] Generating qluamainwindow.moc
[ 44%] Generating qluabrowser.moc
[ 45%] Generating qluaeditor.moc
[ 46%] Generating qluasdimain.moc
[ 48%] Generating qluamdimain.moc
[ 49%] Generating qluamode.moc
[ 50%] Generating qluamode_txt.moc
[ 51%] Generating qluamode_hlp.moc
[ 53%] Generating qluamode_lua.moc
[ 54%] Generating qluamode_c.moc
[ 55%] Generating moc_qluatextedit.cxx
[ 56%] Generating moc_qluaide.cxx
[ 57%] Generating moc_qluamainwindow.cxx
[ 59%] Generating moc_qluabrowser.cxx
[ 60%] Generating moc_qluaeditor.cxx
[ 61%] Generating moc_qluasdimain.cxx
[ 62%] Generating moc_qluamdimain.cxx
Scanning dependencies of target libqtide
[ 63%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qtide.cpp.o
[ 65%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qluatextedit.cpp.o
[ 66%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qluaide.cpp.o
[ 67%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qluamainwindow.cpp.o
[ 68%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qluabrowser.cpp.o
[ 69%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qluaeditor.cpp.o
[ 71%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qluasdimain.cpp.o
[ 72%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qluamdimain.cpp.o
[ 73%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qluamode.cpp.o
[ 74%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qluamode_txt.cpp.o
[ 75%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qluamode_hlp.cpp.o
[ 77%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qluamode_lua.cpp.o
[ 78%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qluamode_c.cpp.o
[ 79%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/qrc_qtide.cxx.o
[ 80%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/moc_qluatextedit.cxx.o
[ 81%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/moc_qluaide.cxx.o
[ 83%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/moc_qluamainwindow.cxx.o
[ 84%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/moc_qluabrowser.cxx.o
[ 85%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/moc_qluaeditor.cxx.o
[ 86%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/moc_qluasdimain.cxx.o
[ 87%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/moc_qluamdimain.cxx.o
[ 89%] Building CXX object packages/qtide/CMakeFiles/libqtide.dir/moc_qluamode.cxx.o
Linking CXX shared module libqtide.so
[ 89%] Built target libqtide
[ 90%] Generating moc_qtluasvggenerator.cxx
Scanning dependencies of target libqtsvg
[ 91%] Building CXX object packages/qtsvg/CMakeFiles/libqtsvg.dir/qtsvg.cpp.o
[ 92%] Building CXX object packages/qtsvg/CMakeFiles/libqtsvg.dir/qtluasvggenerator.cpp.o
[ 93%] Building CXX object packages/qtsvg/CMakeFiles/libqtsvg.dir/moc_qtluasvggenerator.cxx.o
Linking CXX shared module libqtsvg.so
[ 93%] Built target libqtsvg
[ 95%] Generating moc_qtluagui.cxx
Scanning dependencies of target libqtgui
[ 96%] Building CXX object packages/qtgui/CMakeFiles/libqtgui.dir/qtgui.cpp.o
[ 97%] Building CXX object packages/qtgui/CMakeFiles/libqtgui.dir/qtluagui.cpp.o
[ 98%] Building CXX object packages/qtgui/CMakeFiles/libqtgui.dir/moc_qtluagui.cxx.o
Linking CXX shared module libqtgui.so
[ 98%] Built target libqtgui
Scanning dependencies of target libqtuiloader
[100%] Building CXX object packages/qtuiloader/CMakeFiles/libqtuiloader.dir/uiloader.cpp.o
Linking CXX shared module libqtuiloader.so
[100%] Built target libqtuiloader
cd build && make install
[  6%] Built target libqtlua
[ 18%] Built target libqlua
[ 19%] Built target qlua
[ 32%] Built target libqtwidget
[ 33%] Built target libqtcore
[ 89%] Built target libqtide
[ 93%] Built target libqtsvg
[ 98%] Built target libqtgui
[100%] Built target libqtuiloader
Install the project...
-- Install configuration: "Release"
-- Installing: /home/r/torch/install/lib/libqtlua.so
-- Set runtime path of "/home/r/torch/install/lib/libqtlua.so" to "$ORIGIN/../lib"
-- Installing: /home/r/torch/install/include/qtlua/qtluaengine.h
-- Installing: /home/r/torch/install/include/qtlua/qtluautils.h
-- Installing: /home/r/torch/install/include/qtlua/qtluaconf.h
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/conf/cmake/QtLuaConfig.cmake
-- Installing: /home/r/torch/install/lib/libqlua.so
-- Set runtime path of "/home/r/torch/install/lib/libqlua.so" to "$ORIGIN/../lib"
-- Installing: /home/r/torch/install/bin/qlua
-- Set runtime path of "/home/r/torch/install/bin/qlua" to "$ORIGIN/../lib"
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lua/qtwidget/init.lua
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lib/libqtwidget.so
-- Set runtime path of "/home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lib/libqtwidget.so" to "$ORIGIN/../lib"
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lua/qtcore/init.lua
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lib/libqtcore.so
-- Set runtime path of "/home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lib/libqtcore.so" to "$ORIGIN/../lib"
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lib/libqtide.so
-- Set runtime path of "/home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lib/libqtide.so" to "$ORIGIN/../lib"
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lua/qtide/init.lua
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lua/qtide/prefs.lua
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lua/qtide/prefs.ui
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lib/libqtsvg.so
-- Set runtime path of "/home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lib/libqtsvg.so" to "$ORIGIN/../lib"
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lua/qtsvg/init.lua
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lua/qtgui/init.lua
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lib/libqtgui.so
-- Set runtime path of "/home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lib/libqtgui.so" to "$ORIGIN/../lib"
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lua/qtuiloader/init.lua
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lua/qtuiloader/test.lua
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lua/qtuiloader/test.ui
-- Installing: /home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lib/libqtuiloader.so
-- Set runtime path of "/home/r/torch/install/lib/luarocks/rocks/qtlua/scm-1/lib/libqtuiloader.so" to "$ORIGIN/../lib"
Updating manifest for /home/r/torch/install/lib/luarocks/rocks
qtlua scm-1 is now built and installed in /home/r/torch/install/ (license: BSD)

r@server1:~$ 
soumith commented 8 years ago

ok it's the problem of a headless server. I confirmed that if I run the above commands in an ssh environment, totable is not found. If I run the same in the desktop environment with X server available, then totable is found.

thomaspurchas commented 8 years ago

Ok. Thanks for that.

I've now managed to work around that using xvfb and modifying the itorch_launcher to use the xvfb-run command to create a virtual X11 server.

I don't have time to write it all up now, but future people feel free to ping me for details.

soumith commented 8 years ago

ok cool, in the meanwhile, i'll try to remove the qt dependency from the ConfusionMatrix text renderer. Basically, we need to find a way to render text via a simple C library, rather than a monolith like Qt or opencv

farleylai commented 7 years ago

I ran into the same problem with the latest code. Isn't it supposed to figure out the current x server if DISPLAY is set when logged in over ssh? Other viewers such as evince/gedit work as expected over ssh. Is there any updates or am I missing something?