Caffe+GPU+Opencv3.1+Python3.5+Anaconda:fatal error: Python.h: No such file or directory - neural-network

Briefly I want to use Caffe these day for my project.
My OS is Ubuntu 14.04, with Opencv3.1+Python3.5+Anaconda+GPU
I have already passed all:
make all
make pycaffe
make test
make runtest
However when can try to make pycaffe, it cannot pass:
Python.h: No such file or directory
Here is my 'makefile.config', and I am sure the 'Python.h' has already in the path, which make me quite confused.
USE_CUDNN := 1
OPENCV_VERSION := 3
ANACONDA_HOME := $(HOME)/anaconda3
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
$(ANACONDA_HOME)/include/python3.5m \
$(ANACONDA_HOME)/lib/python3.5/site-packages/numpy/core/include \
PYTHON_LIB := $(ANACONDA_HOME)/lib
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
USE_PKG_CONFIG := 1
PYTHON_LIBRARIES := boost_python3 python3.5m
PYTHON_INCLUDE := /usr/include/python3.5m \
/usr/lib/python3.5/dist-packages/numpy/core/include
Because I use Python3.5, so I uncomment the following:
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include
PYTHON_LIB := /usr/lib
I really appreciate someone could help,

You have two definitions for PYTHON_INCLUDE: you need to decide if you go for the "python3" flavor, or the "anaconda" flavor...
Where is your python.h file anyway? try in shell
find / -name "Python.h" -type f
and see where it actually is. Then pick the correct settings for PYTHON_INCLUDE in your makefile.config

I almost spent(waisted) one week to configure caffe on Ubuntu 14.04, the reason why it too time consuming is that I am using the newest version of Opencv Python and anaconda. Here I want to share my experience.
Makefile.config
# cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := 1
# Uncomment if you’re using OpenCV 3
OPENCV_VERSION := 3
# CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda
# CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 lines for compatibility.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_50,code=compute_50
# BLAS choice: atlas for ATLAS (default)
BLAS := atlas
# We need to be able to find Python.h and numpy/arrayobject.h.
ANACONDA_HOME := $(HOME)/anaconda3
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
$(ANACONDA_HOME)/include/python3.5m \
$(ANACONDA_HOME)/lib/python3.5/site-packages/numpy/core/include \
# Uncomment to use Python 3 (default is Python 2)
PYTHON_LIBRARIES := boost_python3 python3.5m
# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := $(ANACONDA_HOME)/lib
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
# N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute
# The ID of the GPU that ‘make runtest’ will use to run unit tests.
TEST_GPUID := 0
# enable pretty build (comment to see full commands)
Q ?= #
/.bashrc
#Caffemake
export PYTHONPATH=~/caffe/python/:$PYTHONPATH
#Opencv
export LD_LIBRARY_PATH=/home/kaku/anaconda3/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=”/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH”
Notes:
1. library must be installed:
libboost-all-dev, although in some tutorial mentioned must install libboost1.55-all-dev.
protobuf-cpp-3.0.0-beta-2.zip or upper one
protobuf-python-3.0.0-beta-2.zip or upper one
http://blog.csdn.net/lien0906/article/details/51784191
https://github.com/google/protobuf/issues/1276
Other Debug: Details in my own blog.

After facing same issue and being on Gentoo system I tried something else. I have 2 python instances installed at same time via Gentoo slots:
ares ~ # eselect python list
Available Python interpreters, in order of preference:
[1] python3.4
[2] python2.7
My default was 2.7, so I tried to switch to 3.4. Well problem is that it required some changes in 2 files.
I note that similar changes with 2.7 simply didn't work, the path was correct, but something is broken underlying...
Makefile.config file I changed to work with Python 3 (3.4) :
PYTHON_LIBRARIES := boost_python3 python3.4m
PYTHON_INCLUDE := /usr/include/python3.4m \
/usr/lib64/python3.4/site-packages/numpy/core/include
Still, when you just change this, it won't work as soon as CMake still points to 2.7. I checked by doing:
mkdir build; cd build;cmake ..;
And the output was:
-- Python:
-- Interpreter : /usr/bin/python2.7 (ver. 2.7.12)
-- Libraries : /usr/lib64/libpython2.7.so (ver 2.7.12)
-- NumPy : /usr/lib64/python2.7/site-packages/numpy/core/include (ver 1.12.1)
So I changed this line in CMakeLists.txt file:
set(python_version "2" CACHE STRING "Specify which Python version to use")
To (change value 2 to 3):
set(python_version "3" CACHE STRING "Specify which Python version to use")
And did cmake again(after cleanup) and got finally:
-- Python:
-- Interpreter : /usr/bin/python3 (ver. 3.4.5)
-- Libraries : /usr/lib64/libpython3.4m.so (ver 3.4.5)
-- NumPy : /usr/lib64/python3.4/site-packages/numpy/core/include (ver 1.12.1)
Now the make -j8 command finish without issues. I note I used multithread option on compile (-j8) as I found on some forums suggesting to go only with -j1 (single thread), so this was not the case for me.

I have the followings in my Make.config:
PYTHON_LIB := /usr/lib
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include
And the following in my ~/.bashrc:
export PYTHONPATH=$HOME/caffe/python
export CAFFE_ROOT=$HOME/caffe
You have to run the following in cd $CAFFE_ROOT:
make all
make pycaffe
make test
make runtest
My setup is in CentOS and for Python 2.7 but it should be a similar idea.
[jalal#ivcgpu1 caffe]$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core
[jalal#ivcgpu1 caffe]$ uname -a
Linux ivcgpu1.bu.edu 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Related

Android HAL .so not build

I was following this guide to learn HAL layer and framework layer in AOSP. I've managed to run the whole process. But there's one small issue. When I build the whole ROM/Android, hello.default.so won't be built/shown up in the following,
${output}/system/lib/hw
${output}/system/lib64/hw
${output}/vendor/lib/hw
${output}/vendor/lib64/hw
Only by manually executing mmm hardware/libhardware/modules/hello/, can I get the hello.default.so.
I have remember to append the module into PRODUCT_PACKAGES macro as following. Packages/Modules vim, hello-lkm-client have been successfully integrated. But not the hello.default module.
PRODUCT_PACKAGES += \
vim
PRODUCT_PACKAGES += \
hello-lkm-client
PRODUCT_PACKAGES += \
hello.default
Here's the Android.mk file for the hello HAL
include $(CLEAR_VARS)
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_PROPRIETARY_MODULE := true
LOCAL_SHARED_LIBRARIES := liblog
#############
# I'm following $hw/modules/gralloc/Android.mk
#############
LOCAL_MODULE_TAGS := optional
LOCAL_PRELINK_MODULE := false
# LOCAL_C_INCLUDES := hardware/libhardware
LOCAL_SRC_FILES := hello.c
LOCAL_HEADER_LIBRARIES := libhardware_headers
LOCAL_MODULE := hello.default
# LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
include $(BUILD_SHARED_LIBRARY)
Here's the complete hello HAL module.
OK, found it. I have to add the hello module in Android.mk of Module modules, just like the following.
chang#ryzen:~/bulk2/rockpi4-atv9-chang/hardware/libhardware$ git diff
diff --git a/modules/Android.mk b/modules/Android.mk
index a430a650..7bbeaeb9 100644
--- a/modules/Android.mk
+++ b/modules/Android.mk
## -2,5 +2,6 ## hardware_modules := \
camera \
gralloc \
sensors \
- hw_output
+ hw_output \
+ hello

Error with static compilation Qt with postgresql driver

I have installed through Mainteinance Tool Qt 5.12.5 and the sources. I have the next directories:
C:\Qt\5.12.5\Src
C:\Qt\Tools\mingw730_32\
C:\Qt\Tools\mingw730_64\
On the other hand, I have read that downloable Postgres version is compiled with MSVC, and I must to compile my own version. I have do it following link, and now I have a postgresql version in c:\pgsql
Finally I have added c:\pgsql to user Path
Next step, I have opened PowerShell in Admin mode and I´ve gone to C:\Qt\5.12.5\Src\.
Next, set the env path for this PowerShell session:
$env:Path += ";C:\Qt\Tools\mingw730_64\bin\;C:\Qt\5.12.5\Src;C:\pgsql\include\;C:\pgsql\lib\;C:\pgsql\bin\" (setting the pgsql path again....)
After that, I execute configure.bat like that:
configure -v -static -release -static-runtime -platform win32-g++ -prefix C:\Qt\5.12.5\Estatico\ -opensource -confirm-license -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -no-openssl -opensource -confirm-license -skip webengine -make libs -nomake tools -nomake examples -nomake tests -sql-psql
But I have get this error:
ERROR: Feature 'sql-psql' was enabled, but the pre-condition 'libs.psql' failed.
Searching in config.log I can read those lines:
loaded result for library config.qtbase_sqldrivers.libraries.psql
Trying source 0 (type pkgConfig) of library psql ...
pkg-config use disabled globally.
=> source produced no result.
Trying source 1 (type psqlConfig) of library psql ...
pg_config not found.
=> source produced no result.
Trying source 2 (type psqlEnv) of library psql ...
None of [liblibpq.dll.a liblibpq.a libpq.dll.a libpq.a libpq.lib] found in [] and global paths.
=> source produced no result.
Trying source 3 (type psqlEnv) of library psql ...
=> source failed condition '!config.win32'.
test config.qtbase_sqldrivers.libraries.psql FAILED
What can I do or what is the properly way to do that?
Thank you in advance.
UPDATE
There are similar question here but it hasn´t been solved, and those question ask about Visual Studio.
I want to compile it under mingw.
The solution suggested by #Soheil Armin doesn´t work too
The solution suggested by #Soheil Armin works fine, but I need to delete the entire source tree and reinstall it as he suggested. If not, a new configure won't work.
Also, the ^ character can be saved:
configure <your parameters>
PSQL_LIBS="C:\pgsql\lib\libpq.a"
-I "C:\pgsql\include"
-L "C:\pgsql\lib"
You need to explicitly define library paths of Postgres.
configure <your parameters> ^
PSQL_LIBS="C:\pgsql\lib\libpq.a" ^
-I "C:\pgsql\include" ^
-L "C:\pgsql\lib"

Buildroot Config Option for applying custom patch

I am new to buildroot and working to build Linaro with buildroot ..I have multiple fragment kernel config files and specified that in buildroot defconfig.
I have specified a custom kernel patches directory with BR2_LINUX_PATCH_DIR .
I dont have some of the config flags not set which are supposed to be there in the .config files..so i suspect that the Patches are applied successfully..so i tried giving a non existing location as Linux Patch dir and it does not give any error..
Is there anything other than giving value to BR2_LINUX_PATCH_DIR and what should be the format of the dir structure...in buildroot manual it says it should be
Package_name/patch name..For linux what should be the package name? It should be the same with which linux dir is created.for example for me it is linux-custom
Plz suggest and guide me in this.
Thanks in Advance
The option is named BR2_LINUX_KERNEL_PATCH, there is nothing named BR2_LINUX_PATCH_DIR. It applies all patches listed in this option (if those are files), or all files named *.patch if what's given in this option is a directory. See the code in linux/linux.mk:
define LINUX_APPLY_LOCAL_PATCHES
for p in $(filter-out ftp://% http://% https://%,$(LINUX_PATCHES)) ; do \
if test -d $$p ; then \
$(APPLY_PATCHES) $(#D) $$p \*.patch || exit 1 ; \
else \
$(APPLY_PATCHES) $(#D) `dirname $$p` `basename $$p` || exit 1; \
fi \
done
endef
Also, I would recommend that you watch the output of Buildroot: it shows everything it is doing, especially it lists the patches it applied. Look at the line >>> linux .... Patching, which is the marker for the beginning of the patching step of the linux package.

Tokenizer in moses-SMT system stuck even with 10 sentences

I was trying to make a baseline MT system. Just for checking How it works I made Source (S) and Target (T) language corpus of just 2000 sentences. The very first step is to prepare the data for Machine Translation (MT) system. In this step first we have to perform tokenization as mentioned here Baseline SMT. I've used this code:
~/mosesdecoder/scripts/tokenizer/tokenizer.perl -l en \
< ~/corpus/training/news-commentary-v8.fr-en.en \
> ~/corpus/news-commentary-v8.fr-en.tok.en
~/mosesdecoder/scripts/tokenizer/tokenizer.perl -l fr \
< ~/corpus/training/news-commentary-v8.fr-en.fr \
> ~/corpus/news-commentary-v8.fr-en.tok.fr
( say S = French & T = English)
I checked after 2 hours it was still running. I got curious since it was not expected. Then I tried with just ten sentences. To my surprise, it's been 30 minutes and it is still running.
Did I do anything wrong?
PS: OS = Ubuntu 14.04.5 LTS
Sony ultrabook
No dual boot.
Please Follow bellow steps ;
git clone https://github.com/moses-smt/mosesdecoder.git
cd mosesdecoder
git clone https://github.com/moses-smt/giza-pp.git
cd giza-pp
make
mkdir tools
cp giza-pp/GIZA++-v2/GIZA++ giza-pp/GIZA++-v2/snt2cooc.out giza-pp/mkcls-v2/mkcls tools
scripts/tokenizer/tokenizer.perl -l fr < ~/corpus/training/news-commentary-v8.fr-en.fr > ~/corpus/news-commentary-v8.fr-en.tok.fr

CoffeeScript: No output after installation

I'm running Ubuntu 13.04, after installing using:
$ sudo npm install -g coffee-script
..with output..
npm http GET https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/coffee-script
/usr/local/bin/coffee -> /usr/local/lib/node_modules/coffee-script/bin/coffee
/usr/local/bin/cake -> /usr/local/lib/node_modules/coffee-script/bin/cake
coffee-script#1.6.3 /usr/local/lib/node_modules/coffee-script
No commands yields any result, whatsoever:
$ coffee js.coffee
$ coffee -v
$ coffee GiveMeSomeCoffeePlease
I verified that it exists:
$ which coffee
/usr/local/bin/coffee
And the file has some contents:
$ cat `which coffee`
#!/usr/bin/env node
var path = require('path');
var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
require(lib + '/coffee-script/command').run();
Also tried version 1.6.1 which works on my laptop. No difference on this computer though. Any ideas?
I finally found the solution. I had installed the package node on Ubuntu, which is something entirely different:
Amateur Packet Radio Node program (transitional package) The
existing node package has been renamed to ax25-node. This transitional
package exists to ease the upgrade path for existing users.
I went ahead and installed the nodejs package. But seems it didn't quite create the right binding anyway, I could run nodejs but not node. So I made an alias for it and now CoffeeScript is running just fine!
cd /usr/bin; sudo ln -s nodejs node
Same here .. In my expressjs app, instead of running via
node app
now it seems I have to run it via
nodejs app
I ll either create an alias or a symlink like Mika did. I am using Ubuntu 13.10 fyi.