karpathy / neuraltalk2

Efficient Image Captioning code in Torch, runs on GPU
5.51k stars 1.26k forks source link

Error: unable to locate HDF5 header file at hdf5.h #123

Open kryptonish opened 8 years ago

kryptonish commented 8 years ago

In order to get neuralTalk2 working on my mac, I have looked at all possible issues that could creep up. My issues are very similar to post #10 , by trych. However, "luarocks install loadcaffe" after which neuraltalk2 seems to be working ,finally, when I run the "th" command, I get the error as shown in the heading of this post. I hope I can some assistance

screenshot 2016-07-14 14 23 01
tbornt commented 8 years ago

I got the same issue and finally I found the solution. If you install hdf5 using brew install hdf5 and after you installed torch-hdf5, you should configure conf.lua at Users/your_name/torch/install/share/lua/5.1/hdf5. Replace the HDF5_INCLUDE_PATH = "/usr/local/Cellar/hdf5/your_version_number/include". Replace your_name and your_version_number based on your settings.

elSupremo commented 8 years ago

Thanks! it works alright :)

anthonyyuan commented 7 years ago

when i use this solution ! but error is appear !!!

my conf.lua hdf5._config = { HDF5_INCLUDE_PATH = "/usr/local/Cellar/hdf5/1.8.17/include", HDF5_LIBRARIES = "/usr/local/lib/libhdf5_cpp.dylib;/usr/local/lib/libhdf5.dylib;/usr/local/lib/libsz.dylib;/usr/local/lib/libz.dylib;/usr/lib/libdl.dylib;/usr/lib/libm.dylib" } ~
~

anthonyyuan commented 7 years ago

th eval.lua -model model_id1-501-1448236541.t7_cpu.t7 image/1.jpg /Users/anthonyyuan/torch/install/bin/luajit: ...s/anthonyyuan/torch/install/share/lua/5.1/trepl/init.lua:384: ...s/anthonyyuan/torch/install/share/lua/5.1/trepl/init.lua:384: /Users/anthonyyuan/.luarocks/share/lua/5.1/hdf5/ffi.lua:42: Error: unable to locate HDF5 header file at hdf5.h stack traceback: [C]: in function 'error' ...s/anthonyyuan/torch/install/share/lua/5.1/trepl/init.lua:384: in function 'require' eval.lua:8: in main chunk [C]: in function 'dofile' ...yuan/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk [C]: at 0x0107482bc0

ashwinroot commented 7 years ago

@anthonyyuan were u able to solve the error?

hassanshallal commented 7 years ago

Yes, I can read and write to hdf5 now

On Mar 2, 2017, at 1:23 AM, Ashwin Sankar notifications@github.com wrote:

@anthonyyuan were u able to solve the error?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

ashwinroot commented 7 years ago

@hassanshallal I am using MAC OS sierra. I m still not able to download a suitable version of hdf5. I followed a lot of tutorial, yet the program throws error related to hdf5 parsing.

module 'hdf5' not found:Failed loading module hdf5 in LuaRocks rock hdf5 0-0

And while trying to install hdf5 from the steps given using github repo, I get an error as:

Could NOT find HDF5: Found unsuitable version "", but required is at least "1.8" (found HDF5_hdf5_LIBRARY-NOTFOUND)

Is there any way I could clean the installations of hdf5 and start afresh ?

liuxx2016 commented 7 years ago

@tbornt Replace the HDF5_INCLUDE_PATH = "/usr/local/Cellar/hdf5/your_version_number/include". what' s the Cellar? I don't have the folder.

GiriB commented 7 years ago

@liuxx2016 You should have brew installed to have the Cellar folder.

swang commented 7 years ago

For anyone getting to this page from Google and trying to figure out how to get HDF5 to run..

First, Follow the suggestion here: http://www.jeffreythompson.org/blog/2016/03/25/torch-rnn-mac-install/comment-page-2/#comment-287591

Update: I overcame this by tapping the older brew version
I ran:

brew install hdf5@1.8

then dumped the folder contents from usr/local/Cellar/hdf5@1.8 into from usr/local/Cellar/hdf5

I then ran

brew switch hdf5 1.8.18

to choose the right hdf5 version

I made my include path in config.lua

HDF5_INCLUDE_PATH = “/usr/local/Cellar/hdf5/1.8.18/include”,

I’m sure there’s a better way of teaching brew which version to default to without dragging folders around but at least it works!

When you run brew install hdf5@1.8, it creates a folder called hdf5@1.8 in the Cellar. That folder contains a 1.18.x folder, where x is some patch version number. That's the folder that should be in /usr/local/Cellar/hdf5/

Make sure you see what version you are actually downloading. For example, as of this writing the latest 1.8.x version of hdf5 is 1.8.19.

Make sure your HDF5_INCLUDE_PATH includes the correct version number. ALSO make sure HDF5_LIBRARIES points to the proper libhdf5 library. For example with 1.8.19, you need to include /usr/local/Cellar/hdf5/1.8.19/lib/libhdf5.dylib in HDF5_LIBRARIES.

After you get this properly, you should encounter an error when you run th -e "require 'hdf5'"

Via https://github.com/deepmind/torch-hdf5/issues/83#issuecomment-254427843

You need to change line 44 of that ffi.lua file from local process = io.popen("gcc -E " .. headerPath) -- TODO pass -I to local process = io.popen("gcc -D '_Nullable=' -E " .. headerPath) -- TODO pass -I

I hope this helps people searching from Google

Benimation commented 7 years ago

For some reason my config file contained this: HDF5_INCLUDE_PATH = "/usr/local/Cellar/hdf5/1.8.19/include;/usr/local/opt/szip/include"

Which I simply changed to this: HDF5_INCLUDE_PATH = "/usr/local/Cellar/hdf5/1.8.19/include"

I have no idea where the extra ;/usr/local/opt/szip/include came from..

It now works, I am using macOS High Sierra (10.13)

jianchao-li commented 6 years ago

Hi, @Benimation. I came across the same problem and removing /usr/local/Cellar/hdf5/1.8.19/include also seemed to work for me.