libjpeg.so libpng.so Error

1,790 views
Skip to first unread message

Anoop Katti

unread,
Feb 12, 2015, 6:26:05 AM2/12/15
to tor...@googlegroups.com
I have installed Torch7 on CentOS 6.5. From qlua or from iTorch, when I run the following commans: 

require 'image'
image.display(image.lena()),

I get the following error:

error loading module 'libjpeg' from file '/home/anurag/torch/install/lib/lua/5.1/libjpeg.so':
	/home/anurag/torch/install/lib/lua/5.1/libjpeg.so: undefined symbol: jpeg_mem_src
warning: <libjpeg> could not be loaded (is it installed?)
Out[2]:
error loading module 'libpng' from file '/home/anurag/torch/install/lib/lua/5.1/libpng.so':
	/home/anurag/torch/install/lib/lua/5.1/libpng.so: undefined symbol: png_set_longjmp_fn
warning: <libpng> could not be loaded (is it installed?)
/home/anurag/torch/install/share/lua/5.1/dok/inline.lua:629: <image.lena> no bindings available to load images (libjpeg AND libpng missing)
stack traceback:
	[C]: in function 'error'
	/home/anurag/torch/install/share/lua/5.1/dok/inline.lua:629: in function 'error'
	/home/anurag/torch/install/share/lua/5.1/image/init.lua:1071: in function 'lena'
	[string "local f = function() return image.display(ima..."]:1: in function 'f'
	[string "local f = function() return image.display(ima..."]:1: in main chunk
	[C]: in function 'xpcall'
	/home/anurag/torch/install/share/lua/5.1/itorch/main.lua:194: in function </home/anurag/torch/install/share/lua/5.1/itorch/main.lua:160>
	/home/anurag/torch/install/share/lua/5.1/lzmq/poller.lua:75: in function 'poll'
	/home/anurag/torch/install/share/lua/5.1/lzmq/impl/loop.lua:307: in function 'poll'
	/home/anurag/torch/install/share/lua/5.1/lzmq/impl/loop.lua:325: in function 'sleep_ex'
	/home/anurag/torch/install/share/lua/5.1/lzmq/impl/loop.lua:370: in function 'start'
	/home/anurag/torch/install/share/lua/5.1/itorch/main.lua:374: in main chunk
	[C]: in function 'require'
	(command line):1: in main chunk
	[C]: at 0x00404670

When I run the "nm -g" command on the *so files, I find the symbols defined.

I even re-installed image library by downloading the source and running "luarocks make". Please help. Thanks :)

soumith

unread,
Feb 12, 2015, 6:30:23 AM2/12/15
to torch7 on behalf of Anoop Katti
you probably need libjpeg and libpng installed on your centos 6.5 machine. sudo yum install libjpeg-devel libpng-devel
Then you might have to reinstall the image package: luarocks install image

--
You received this message because you are subscribed to the Google Groups "torch7" group.
To unsubscribe from this group and stop receiving emails from it, send an email to torch7+un...@googlegroups.com.
To post to this group, send email to tor...@googlegroups.com.
Visit this group at http://groups.google.com/group/torch7.
For more options, visit https://groups.google.com/d/optout.

Anoop Katti

unread,
Feb 12, 2015, 6:53:09 AM2/12/15
to tor...@googlegroups.com
libjpeg and libpng already installed and are latest version. Besides, Torch builds its own libjpeg and libpng right?


On Thursday, February 12, 2015 at 5:00:23 PM UTC+5:30, smth chntla wrote:
you probably need libjpeg and libpng installed on your centos 6.5 machine. sudo yum install libjpeg-devel libpng-devel
Then you might have to reinstall the image package: luarocks install image

soumith

unread,
Feb 12, 2015, 7:46:20 AM2/12/15
to torch7 on behalf of Anoop Katti
Anoop, torch does not build it's own libpng/libjpeg. it compiles lua wrappers around the existing libpng/libjpeg if they are found on the system.

Anoop Katti

unread,
Feb 13, 2015, 11:56:37 AM2/13/15
to tor...@googlegroups.com
I think the problem is with the currently installed version of the libpng/libjpeg. I have installed a new version in my home folder, since I do not have sudo permissions. How do I force the torch wrapper file to be linked with this new libpng?? 

I tried updating the LD_LIBRARY_PATH and re-installing "image" library with "luarocks make". The newly generated torch wrapper still points to the same old libpng.


On Thursday, February 12, 2015 at 6:16:20 PM UTC+5:30, smth chntla wrote:
Anoop, torch does not build it's own libpng/libjpeg. it compiles lua wrappers around the existing libpng/libjpeg if they are found on the system.

Anoop Katti

unread,
Feb 13, 2015, 12:23:29 PM2/13/15
to tor...@googlegroups.com
The new version of libpng is 1.6.16, while the old one is 1.2.49. Just giving more info..Thanks

Rahul Krishnan

unread,
Jun 15, 2015, 2:46:23 PM6/15/15
to tor...@googlegroups.com
Hi, 

I had the same problem. This is how I solved it. 

1) Install libjpeg locally on your machine. I used the version found here: http://www.ijg.org/
Lets assume its installed into : /path/to/jpeg

2) Clone the git repository for image (found here: https://github.com/torch/image.git)  into your local directory

3) Modify CMakeLists.txt like so:
-Comment out FIND_PACKAGE(JPEG REQUIRED)

-Replace the block of code that looks like:
if (JPEG_FOUND)
    SET(src jpeg.c)
    include_directories (${JPEG_INCLUDE_DIR})
    ADD_TORCH_PACKAGE(jpeg "${src}" "${luasrc}" "Image Processing")
    TARGET_LINK_LIBRARIES(jpeg luaT TH ${JPEG_LIBRARIES})
else (JPEG_FOUND)
    message ("WARNING: Could not find JPEG libraries, JPEG wrapper will not be installed")
endif (JPEG_FOUND)

with:

SET(src jpeg.c)
SET(JPEG_LIBRARY /path/to/jpeg/lib/libjpeg.so)
SET(JPEG_INCLUDE_DIR /path/to/jpeg/include)
include_directories (${JPEG_INCLUDE_DIR})
message( "Using JPEG_INCLUDE_DIR in ${JPEG_INCLUDE_DIR}")
ADD_TORCH_PACKAGE(jpeg "${src}" "${luasrc}" "Image Processing")
TARGET_LINK_LIBRARIES(jpeg luaT TH ${JPEG_LIBRARY})

This forces the installation of the JPEG wrapper and the variables JPEG_LIBRARY and JPEG_INCLUDE_DIR hardcode the path of your headers and the .so file.


This worked for me. Hope this helps. 

Cheers,
Rahul

Chen Sun

unread,
Aug 12, 2015, 3:25:34 PM8/12/15
to torch7
Hi,

I've experienced the same problem on a CentOS 6.6 server, and followed your instruction to modify the cmake file.
The 'image' package stops complaining about libjpeg, but the loaded image is clearly corrupted. For example, when I run lena() four times, I got:
th> image.lena():mean()
3.023673343968e-37
                                                                      [0.0710s]
th> image.lena():mean()
1.559614693423e-26
                                                                      [0.0448s]
th> image.lena():mean()
4.350670500752e-25
                                                                      [0.0350s]
th> image.lena():mean()
4.3019842036534e-14

Any idea how to address this? Thanks!

Best,
Chen

Subbu Rama

unread,
Dec 21, 2015, 10:54:24 PM12/21/15
to torch7
Hi Chen and others,

I know this is a bit dated thread,  but thought I would still ask. Were you guys able to solve the problem of libjpeg + torch7 with centOS6.6. I m recently trying to install torch7 on a centos6.6 machine (i know its a pretty old OS, but i hve to somehow get it working on that OS :( ), and was getting this error: "undefined symbol: jpeg_mem_src". Then, I tried to resolve it by updating the libjpeg version to 8.0, but now I m getting a different error, like the one below. Any thoughts or tips?  

~/torch/install/share/lua/5.1/image/init.lua:212: Wrong JPEG library version: library is 80, caller expects 62

Anyways, I created a new post in the group (https://groups.google.com/forum/#!topic/torch7/hdjnsbDAayo) , but thought I would ask this thread since looks like Chen and Anoop seemed to have had similar problems.

Any help appreciated. 

Thanks
Subbu

Anoop Katti

unread,
Dec 22, 2015, 1:13:41 AM12/22/15
to torch7 on behalf of Subbu Rama
libpng16.so.16.17.0 and libjpeg.so.8.4.0 worked for me.
Although, I did not install it system wide since other programs used the older version. Instead, I used the libjpeg and libpng of anaconda installed in the home directory.
I did this by temporarily renaming the system libjpeg, installing torch7 and changing back the names of system libjpeg.

--
You received this message because you are subscribed to a topic in the Google Groups "torch7" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/torch7/uzEouI3pwhA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to torch7+un...@googlegroups.com.

To post to this group, send email to tor...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
MS (Computer Vision), CSE, IIT-Madras.

Subbu Rama

unread,
Dec 22, 2015, 5:30:09 PM12/22/15
to torch7 on behalf of Anoop Katti
Thank you Anoop for the note. I already tried the steps you suggested. Forced the $PATH to pick the libjpeg8 I installed (instead of the libjpeg6.2), and re-installed torch so that it links to that as well.

I m doing this on centos6.6, and the problem I face is that I already have libjoeg8.0 and torch seems to be point to that, but its expecting 6.2 version of libjoeg.

~/torch/install/share/lua/5.1/image/init.lua:212: Wrong JPEG library version: library is 80, caller expects 62

Any thoughts on what would be expecting the 6.2 version of libjpeg?


Btw, here is what I get when I did ldd on libjpeg installed in the torch directory.

$> ldd ~/torch/install/lib/lua/5.1/libjpeg.so 

linux-vdso.so.1 =>  (0x00007fff9c9ff000)

libluaT.so =>~/torch/install/lib/libluaT.so (0x00002ba1cdab3000)

libTH.so => ~/torch/install/lib/libTH.so (0x00002ba1cdcbc000)

libjpeg.so.8 => ~/jpeg_dir/lib/libjpeg.so.8 (0x00002ba1ce0b0000)

libblas.so.3 => /usr/lib64/libblas.so.3 (0x00002ba1ce301000)

liblapack.so.3 => /usr/lib64/atlas/liblapack.so.3 (0x00002ba1ce559000)

librt.so.1 => /lib64/librt.so.1 (0x00002ba1ced7a000)

libgomp.so.1 => /usr/lib64/libgomp.so.1 (0x00002ba1cef82000)

libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ba1cf198000)

libc.so.6 => /lib64/libc.so.6 (0x00002ba1cf3b5000)

/lib64/ld-linux-x86-64.so.2 (0x00002ba1cd688000)

libm.so.6 => /lib64/libm.so.6 (0x00002ba1cf749000)

libgfortran.so.3 => /usr/lib64/libgfortran.so.3 (0x00002ba1cf9ce000)

libf77blas.so.3 => /usr/lib64/atlas/libf77blas.so.3 (0x00002ba1cfcc0000)

libcblas.so.3 => /usr/lib64/atlas/libcblas.so.3 (0x00002ba1cfedf000)

libatlas.so.3 => /usr/lib64/atlas/libatlas.so.3 (0x00002ba1d0100000)



Best
Subbu

Trying to schedule a meeting with me? Check my availability here.

Abin Jose

unread,
Jul 22, 2016, 8:55:10 AM7/22/16
to torch7
Hey subbu,

how did you resolve this issue. I am having similar problem.

Cong Leng

unread,
Feb 12, 2017, 10:27:06 PM2/12/17
to torch7
Hi, I have the same problem with you. This is how I solved it.

The problem is not in the LD_LIBRARY_PATH but in the CMAKE_LIBRARY_PATH. Since CMAKE find the relevant libraries in /usr/loal/** by default, in order to change this you should explicitly export this variable. For example, add such a line in your .bashrc:

export CMAKE_LIBRARY_PATH=/path/to/your/jpeg/library/files
export CMAKE_INCLUDE_PATH=/path/to/your/jpeg/include/files

Bests

在 2015年2月14日星期六 UTC+8上午12:56:37,Anoop Katti写道:
Reply all
Reply to author
Forward
0 new messages