How do I get the right libjpeg dylib for Lua? - lua

So, I am running torch on OSX (See error in bold below):
______ __ | Torch7
/_ __/__ ________/ / | Scientific computing for Lua.
/ / / _ \/ __/ __/ _ \ |
/_/ \___/_/ \__/_//_/ | https://github.com/torch
| http://torch.ch
th> package.cpath = package.cpath .. ";/usr/local/Cellar/jpeg/8d/lib/?.dylib"
[0.0000s]
th> require 'image'
true
[0.0120s]
th> image.lena();
/Users/<user>/torch/install/share/lua/5.1/trepl/init.lua:319: error loading module 'libjpeg' from file '/usr/local/Cellar/jpeg/8d/lib/libjpeg.dylib':
dlsym(0x7fd564000320, luaopen_libjpeg): symbol not found
warning: <libjpeg> could not be loaded (is it installed?)
[0.0229s]
th>
Specifically this line:
error loading module 'libjpeg' from file '/usr/local/Cellar/jpeg/8d/lib/libjpeg.dylib':
dlsym(0x7fd564000320, luaopen_libjpeg): symbol not found
warning: could not be loaded (is it installed?)
Seems like I don't have the right dylib? If so, where do I get it?

this happens when there's two libjpeg's installed on your machine, and one conflicts with another.
start torch like this:
export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH
th
it should hopefully work with this.

Related

Grep finds the word and then stucks (bash)

I have a loop (while, extracting 2 variables) where I found one command is not working. Even when I put the command in the console directly (subsituting by my own the variable) it gives the result but continue working without any advance.
The command's objective is to find in a big file.gct, in specific in its first three lines, an object obtained from other file and then print the finding and everything before in that line.
If someone know why it stucks and how to fix it or even an alternative that works well in loops and does not demands more RAM's use it would be appreciated.
head -3 file_2 | grep -E -o ".{0,1000}$variable."
Kind of an example as how it looks the big file (file_2):
head -3 file_2
| #1.2 |
| 57000 | 17300 |
|Irrelevant|Irrelevant2| DATA-B12-18 | DATA-Y17-72 | DATA-A12-44 | .... |
When I run in the terminal: head -3 file_2 | grep -E -o ".{0,1000}DATA-B12-18"
the output is:
Irrelevant Irrelevant2 DATA-B12-18 and then stacks.

torch.CharStorage doesn't read data from a file when size isn't provided

I'm trying to replicate the example provided here. In my case, though, when I do the torch.CharStorage('hello.txt') I get [torch.CharStorage of size 0]. Here's the full output
$ echo "Hello World" > hello.txt
$ th
______ __ | Torch7
/_ __/__ ________/ / | Scientific computing for Lua.
/ / / _ \/ __/ __/ _ \ | Type ? for help
/_/ \___/_/ \__/_//_/ | https://github.com/torch
| http://torch.ch
th> x = torch.CharStorage('hello.txt')
[0.0001s]
th> x
[torch.CharStorage of size 0]
I also noticed that when I do torch.CharStorage('hello.txt', false, 11) the data is read correctly. However, in documentation the shared and size parameters are specified as optional. Is it the case that the documentation is not up to date or am I doing something wrong?
You appear to be running into distro bug #245, introduced by commit 6a35cd9. As stated in torch7 bug #1064, you can work around it by either updating your pkg/torch submodule to commit 89ede3b or newer, or rolling it back to commit 2186e41 or older.

How to fix '/bin/bash: th: command not found' error in torch on Google Colaboratory

Please, I need to run !th luafile.lua in colab.
After installing torch following this link, I run !thbut obtained this error:
/bin/bash: th: command not found
I lsinto /root/torch/install/bin. No th* is present:
json2lua* lua2json* luajit* luarocks* luarocks-admin* mdcat*
Please can anyone help me?
Hard but easy
Clone the Torch repo (forked to work with CUDA 10).
!git clone https://github.com/nagadomi/distro.git torch --recursive
Install Torch.
import os
os.chdir('./torch/')
!bash install-deps
!./install.sh
Activate Torch.
!. ./install/bin/torch-activate
Make sure the installation worked.
!./install/bin/th
Result:
______ __ | Torch7
/_ __/__ ________/ / | Scientific computing for Lua.
/ / / _ \/ __/ __/ _ \ | Type ? for help
/_/ \___/_/ \__/_//_/ | https://github.com/torch
| http://torch.ch
th> ^C

"fd:6: hGetLine: end of file" in Cryptol

I've compiled and installed both cvc4 from source code. Cvc4 was downloaded and installed as suggested, and Cryptol was downloaded from it's git repository. The sandboxing, and installation finished without error (with GHC 7.8.3 x86_64). The issue occurs only after invoking cryptol, and issuing a :prove True. Here is everything:
athan#namek ~/lib> cryptol
_ _
___ _ __ _ _ _ __ | |_ ___ | |
/ __| '__| | | | '_ \| __/ _ \| |
| (__| | | |_| | |_) | || (_) | |
\___|_| \__, | .__/ \__\___/|_|
|___/|_| version 2.1.0 (8898348)
Loading module Cryptol
Cryptol> :prove True
cryptol: fd:6: hGetLine: end of file
athan#namek ~/lib>
Any help with this would be tremendous. To me, it feels like there's a shared library not found. Would that cause this issue? Thank you.
Summarizing the conversation in the comments:
The "end of file" error mentioned in the question is commonly attributed to the prover of interest (CVC4 in this case) being only "partially installed" - in my cases this was always an issue with shared libraries that could be discovered by invoking the binary (cvc, boolector, etc) from the command line. The ticket for the bug where the REPL would terminate is on Cryptol's github. Fortunately, this issue was fixed in upstream SBV and will appear in Cryptol's fork of SBV soon.
WRT AthanClark's particular case it is still unknown why and how CVC4 was failing when invoked by Cryptol - possibilities include cryptol invoking a different binary than the one we are expecting or environmental differences, such as the LD_LIBARARY path variable. Either way, it sounds like he was able to use an alternative prover (boolector) successfully.
EDIT: If you can produce Athan's bug, where CVC works outside of SBV and not inside of SBV... and you live in Portland then shoot me a message, show up at my office and show me, I'd be interested.

Changing working directory in Erlang shell under Windows

I have Erlang installed on my WinXP machine. Becouse so, I use it by a "werl.exe". The problem is, that I would like to change a default folder that werl starts in. I cannot find option that would let me do that, although I know there must be something like that.
Could anybody help ?
If you want to change directory at run time in the emulator then use the built in function cd as below..
72> cd("c:/Sandbox/erl").
c:/Sandbox/erl
ok
Note: You need to use the forward slash and not backward slash as you would normally do in windows.
You can specify initial settings in a .erlang file
It should be located C:\Program Files (x86)\erlX.X.X\usr.erlang (where X.X.X is the version number...)
If there isn't any then feel create one (note: you'll likely need to run your editor with administrative privileges to create the .erlang file in the appropriate location).
Here is a simple example for the content:
io:format("C:/Program Files (x86)/erl5.10.4/usr/.erlang\n").
io:format(" ______ _ \n").
io:format("| ____| | | \n").
io:format("| |__ _ __| | __ _ _ __ __ _ \n").
io:format("| __| | '__| |/ _` | '_ \\ / _` |\n").
io:format("| |____| | | | (_| | | | | (_| |\n").
io:format("|______|_| |_|\\__,_|_| |_|\\__, |\n").
io:format(" __/ |\n").
io:format(" |___/ \n\n").
shell_default:cd("C:/Documents/MyErlangProjects").
Notice the use of *nix-like forward-slashes (i.e. "/") rather than the typical Windows convention of using back-slashes (i.e. "\").
It can be tested by running an erlang shell and on startup it will print this cool ASCII stuff :). Beware, the cool ascii stuff doesn't mean a valid working directory was specified!
Of course the main important line is the last one:
shell_default:cd("C:/Documents/MyErlangProjects"). where you specify which directory you want to start with as the current working directory.
Enjoy.
Thank you all.
It was just as easy as typing a desired path in the "Start in" option in the "preferences" of shortcut to werl.exe.
If you want to run Erlang in many different projects in different directories I found the easiest most basic solution is to create separate .bat files in each directory. Clicking on one will then run Erlang in the right directory. This makes it easy to set environment variables for Erlang, ERL_LIBS is a good one. It also makes it easy to use different versions at the same time, one .bat file for each version.

Resources