Failed to run Apache Singa after installation - machine-learning

Followed the instruction and installed Apache Singa v1.0.0 from the wheel successfully, but failed to run it below,
(singa) $ pip list | grep singa
singa (1.0.0)
(singa) $ python
> import singa
> ImportError: No module named '_singa_wrap'
(singa) $ find -name "*singa_wrap*"
singa_wrap.py
singa_wrap.pyc
_singa_wrap.so
Seemed something suspicious with Swig module extension. Any suggestions?
#EDIT
Verified that protobuf 2.6.1 already installed globally below,
(singa) $ python -c "from singa import _singa_wrap"
undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameEv
$ ldd _singa_wrap.so
libprotobuf.so.9 => /usr/lib/x86_64-linux-gnu/libprotobuf.so.9
$ dpkg -S libprotobuf.so.9
libprotobuf9v5
$ apt-cache policy libprotobuf9v5
Installed: 2.6.1-1.3
#Solution
Singa starts dancing now after protobuf 2.6.1 being successfully installed locally on Ubuntu 16.04 below,
$ sudo apt-get install python-pip # gcc-5 required thus installed
$ sudo apt-get install gcc-4.8
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5
$ sudo update-alternatives --config gcc # to choose gcc-4.8
The rest then follows the answer #Wei below. Thanks again.

I think you can try the approaches in the first FAQ http://singa.apache.org/en/docs/installation.html#faq
In addition, you can check the dependent libs of _singa_wrap.so (go to /Python2.7/site-packages/singa/, and ldd _singa_wrap.so. If any library (e.g. cudnn or protobuf) is not found, then try to install it or export the library path.
There is a ticket for your issue https://issues.apache.org/jira/browse/SINGA-255.
Will update you once it is done.
Thanks.
UPDATE:
It seems your error is related to protobuf (could be caused by multiple versions of protobuf on your computer). Here is the solution,
Download protobuf (protobuf-2.6.1.tar.gz on github) and decompress the tar file
Install protobuf into /home//local/ by
./configure --prefix=/home/<yourname>/local
make && make install
echo "export LD_LIBRARY_PATH=/home/<yourname>/local/lib:$LD_LIBRARY_PATH" >> ~/.bashrc
source ~/.bashrc
pip uninstall singa
pip install <path to the wheel file>

Related

update-alternatives for ant

Can I use update-alternatives on ubuntu to switch between multiple versions of ant? I used the same for switching between g++ versions on ubuntu 14.04 LTS as explained here. Looking for a similar process for multiple ant versions, but not able to find any.
Well, this is how I did it. Luckily, I found the solution soon after posting the question. I should have tried different keywords in google search. Searching "Installing multiple ant versions on ubuntu" took me to this link. Here are the steps that I followed. I had version 1.9.x on my machine (Ubuntu 14.04) and I needed ant 1.8.4:
$ wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.4-bin.tar.bz2
// move current version to stock
$ test -f /usr/share/ant || sudo mv /usr/share/ant /usr/share/apache-ant-stock
$ tar xvf apache-ant-1.8.4-bin.tar.bz2
$ sudo mv apache-ant-1.8.4 /usr/share/
$ sudo update-alternatives --install /usr/share/ant ant-bins /usr/share/apache-ant-1.8.4/ 1
$ sudo update-alternatives --install /usr/share/ant ant-bins /usr/share/apache-ant-stock/ 2
$ sudo update-alternatives --install /usr/bin/ant ant /usr/share/apache-ant-1.8.4/bin/ant 1
$ sudo update-alternatives --install /usr/bin/ant ant /usr/share/apache-ant-stock/bin/ant 2
$ sudo update-alternatives --config ant-bins
$ sudo update-alternatives --config ant
Now I can switch the versions.

Can't install language pack

I'm trying to install italian language pack on a VM instance with Debian. I've tried almost everything but it still can't find the language pack.
$ apt-get update
$ apt-get install language-pack-it-base
$ apt-get install language-pack-it
It returns:
E: Unable to locate package language-pack-it
It's the same with other languages.
Any hint?
To install language-pack-it-base:
$ wget http://archive.ubuntu.com/ubuntu/pool/main/l/language-pack-it-base/language-pack-it-base_14.10+20141020_all.deb
$ sudo dpkg -i language-pack-it-base_14.10+20141020_all.deb
To install language-pack-it:
$ wget http://archive.ubuntu.com/ubuntu/pool/main/l/language-pack-it/language-pack-it_14.10+20141020_all.deb
$ sudo dpkg -i language-pack-it_14.10+20141020_all.deb
Verify the installation of the packages using dpkg -l
$ dpkg -l | grep language-pack-it
‘ii’ status indicates a successful installation.
If you get dependency errors during the installation, run the command below and re-install the packages.
$ sudo dpkg --configure -a

Unable to install erlang on cent os

While installing erlang on cent os I got the following error
Error: Package: erlang-crypto-R16B03-0.2.el6.x86_64 (erlang-solutions)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: erlang-crypto-R16B03-0.2.el6.x86_64 (erlang-solutions)
Requires: libcrypto.so.10(OPENSSL_1.0.1)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
I searched around on google and found that the probelm can be solved by installing openssl-devl. So I did that and tried installing erlang again but got the same error.
How can I install the latest version of erlang on cent os 6.4?
How you are installing it? According to Riak's documentation, you use:
sudo yum install gcc glibc-devel make ncurses-devel openssl-devel autoconf
And then, you build Erlang:
wget http://erlang.org/download/otp_src_R15B01.tar.gz
tar zxvf otp_src_R15B01.tar.gz
cd otp_src_R15B01
./configure && make && sudo make install
Installing Erlang on GNU/Linux
You can install erlang using erlang-solution repo
Install repo
wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
Install erlang
sudo yum install erlang
This worked for me on centos7...
sudo yum install epel-release
sudo yum update
wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
sudo rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
sudo yum install erlang
Using EPEL from Fedora is a surefire way on Centos 6. I currently have erlang-crypto-R14B-04.3.el6.x86_64 installed. If you have different repos enabled it could be a conflict or that there is an issue with the package from the other repo (I would recommend disabling whatever repo that provides it or at least ignoring erlang from that repo).
Here is a simple way to install EPEL on Centos
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
yum -y install erlang-*
your error is
"Error: Package: erlang-crypto-R16B03-0.2.el6.x86_64"
so you can download&install R16B03
wget http://erlang.org/download/otp_src_R16B03.tar.gz
tar -zxvf src_R16B03.tar.gz
cd src_R16B03.tar.gz
yum localinstall erlang
To install erlang in centos offline.Follow below steps,
We need to have one internet connected machine to download rpm's.
yum install yum-plugin-downloadonly -y
yum install --downloadonly --downloaddir=/home/user/ erlang
All of erlang dependencies packages downloaded as rpm on /home/user/ directory
Now copy all rpm's to offline machine in any directory ( eg., /home/user/ )
Type following command to install erlang with its dependencies too.,
cd /home/user/
rpm -Uvh *.rpm
It's Done!
check using command,
erl
(press Ctrl+c twice to get exit from erl command )

wicked_pdf does not run on Ubuntu server : wkhtmltopdf: cannot connect to X server

I'm trying to use wicked_pdf on my prod server but it keeps failling :
RuntimeError (Failed to execute:
"/usr/bin/wkhtmltopdf" -q "file:////tmp/wicked_pdf20130709-23109-1adqx5g.html" "/tmp/wicked_pdf_generated_file20130709-23109-1ic5dbe.pdf"
Error: PDF could not be generated!
Command Error: wkhtmltopdf: cannot connect to X server
):
app/controllers/contrats_controller.rb:15:in `block (2 levels) in show'
app/controllers/contrats_controller.rb:11:in `show'
I tried to follow this answer : wkhtmltopdf: cannot connect to X server but it still does not work.
This post helped me to resolve my problem :
http://www.stormconsultancy.co.uk/blog/development/generating-pdfs-in-rails-with-pdfkit-and-deploying-to-a-server/
I'm reproducing here the step from this post that helped me to install it :
# first, installing dependencies
sudo aptitude install openssl build-essential xorg libssl-dev
# for 64bits OS
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
mv wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf
chmod +x /usr/local/bin/wkhtmltopdf
He also create an initializer to tell to pdfKit where it is, so this method is for wicked PDF and PDF Kit.
Resolved this problem in this tread https://stackoverflow.com/a/34947479/5320149
I found method to resolve this problem without fake X server.
In newest version of wkhtmltopdf dont need X server for work, but it no into official linux repositories.
Solution for Ubuntu 14.04.4 LTS (trusty) i386
$ sudo apt-get install xfonts-75dpi
$ wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-i386.deb
$ sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-i386.deb
$ wkhtmltopdf http://www.google.com test.pdf
Solution for Ubuntu 14.04.4 LTS (trusty) amd64
$ sudo apt-get install xfonts-75dpi
$ wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
$ sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
$ wkhtmltopdf http://www.google.com test.pdf
Verify you have xvfb installed, or install it using apt-get
install xvfb.
Create a file called wkhtmltopdf.sh and add the following:
xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf $*
Change the dimensions (640x480x16) to match whatever virtual screen parameters you want it to emulate.
Move the shell script to /usr/bin, and set permissions:
sudo chmod a+x /usr/bin/wkhtmltopdf.sh
Optionally, you can add a symbolic link in your project directory:
ln -s /usr/bin/wkhtmltopdf.sh wkhtmltopdf
See this and this for reference.

Why cv2.so missing after opencv installed?

Today I installed opencv 2.4.4 to Ubuntu 12.10
But import cv2 not works.
root#-:~# python
Python 2.7.3 (default, Sep 26 2012, 21:53:58)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>>
As I understand cv2.so missed, so python don't see where opencv
root#-:~# find / -name "cv.py"
/root/opencv-2.4.4/modules/python/src2/cv.py
root#-:~# find / -name "cv2.so"
root#-:~#
My setup steps look like
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.4/OpenCV-2.4.4a.tar.bz2
tar -xjf OpenCV-2.4.4a.tar.bz2
cd opencv-2.4.4
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
make && make install
echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf
ldconfig
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig" >> /etc/bash.bashrc
echo "export PKG_CONFIG_PATH" >> /etc/bash.bashrc
Where is cv2.so ? And why it was missed ?
How to install opencv(cv2) with python bindings in Linux - Ubuntu/Fedora
Install gcc, g++/gcc-c++, cmake (apt-get or yum, in case of yum
use gcc-c++)
apt-get install gcc, g++, cmake
Downlaod latest opencv from openCV's website
Untar it with
tar -xvf opencv-*
Inside the untarred folder make a new folder called release
mkdir release
cd release
(or any folder name) and run this command in it
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
the .. will pull files from the parents folder and will get the system ready for
installation on your platform.
in the release folder run
make
After about 2-3 mins of make processing when its finished run
sudo make install
Export python path
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages
That's it, now go to python and try
>>> import cv2
you should not get any error message.
Tested on python 2.7, should be virtually similar to python 3.x.
I install python-opencv to solve my problem in Ubuntu 14.04
sh
sudo apt-get install python-opencv
Using raspbian on a rasberry pi I had the problem of the module not being found also. I had three versions of python (2.6, 2.7, and 3.2), be sure you are using python2.7. You can check this by running:
python --version
I found that for my case it was simply that I needed to install python-dev.
sudo apt-get install python-dev
I did Not have to remove and reinstall opencv, I tried my hardest to avoid that, knowing that it takes a few hours to complete the process.
After installing python-dev I went to the file I built the opencv into, for me it was " ~/opencv-2.4.9/release", and told it to make
sudo make
after this I was able to find the cv2.so file. searching for it with:
find / -name "cv2.so"
at this point I found a few files.
next I ran just the python to see if it could find "import" them
python
>>> import cv2
no errors should come up.
>>> import numpy
I have heard that numpy was necessary for opencv to run.
From there I believe you should be good to run your script, if no errors come about. I hope this helps.
The page that helped me is listed...
http://opencv-users.1802565.n2.nabble.com/I-can-t-find-cv-so-and-cv2-so-after-compiling-td6671937.html
I had a similar problem when I manually configured using CMAKE on OSX El Capitan. I had given this additional option:
PYTHON2_PACKAGES_PATH='lib/python2.7/site-packages'
which stopped the cv2.so in that package from getting installed. It seems to install properly in my build folder after I removed it:
PYTHON2_EXECUTABLE='/usr/bin/python2.7'
PYTHON2_INCLUDE_DIR='/usr/include/python2.7'
PYTHON2_LIBRARY='/usr/lib/libpython2.7.dylib' # TODO - Fix for linux
PYTHON2_NUMPY_INCLUDE_DIRS='/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include' # Todo - Fix for linux
cd $OPENCV_DIR
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$OPENCV_INSTALL_PATH \
-D WITH_CUDA=OFF \
-D BUILD_opencv_python2:BOOL=ON \
-D PYTHON2_EXECUTABLE=$PYTHON2_EXECUTABLE \
-D PYTHON2_INCLUDE_DIR=$PYTHON2_INCLUDE_DIR \
-D PYTHON2_LIBRARY=$PYTHON2_LIBRARY \
-D PYTHON2_NUMPY_INCLUDE_DIRS=$PYTHON2_NUMPY_INCLUDE_DIRS \
-D INSTALL_PYTHON_EXAMPLES:BOOL=ON \
..
make -j8
make install
I have this problem in my OS X El Capitan.
I followed the instructions mentioned in this tutorial. Didn't get a successful working install and had the above error of missing cv2.so file in the required folders mentioned and at the python prompt.
Finally figured that using the virtual python setup was causing trouble. So uninstalled with
pip install virtualenv virtualenvwrapper
Then ran
brew link opencv
which threw errors.
And then followed below steps to resolve the issue.
First run
brew link opencv
If it gives an error, try for an automated diagnosis
brew doctor
brew doctor gives a list of problems that could be leading to errors in installation process.
To fix problems in case of conflicting files,
run to get a list of all actions which will be performed by overwrite without actually performing them.
To list all files that would be deleted:
brew link --overwrite --dry-run opencv
followed by this run which will execute the overwrite, assuming you feel that the actions performed by overwrite will take your system to a more stable state.
To force the link and overwrite all conflicting files:
brew link --overwrite opencv
This tutorial is a simpler alternative.
None of the above worked for me; am in Ubuntu 16.04 on an ec2 instance & had anaconda installed so I just used
conda install opencv for both my conda2 and 3 installs
All above answers did not work for me, however, after a whole day struggling, I finally solved this problem.
To have cv2.so, we need:
At least python 2 or 3 installed. that why people say: sudo apt-get install python-dev. But that's not necessary, in my case, I use anaconda python. (there are many ways to install python)
numpy is also a must. so, whatever python you use, just make sure you have it downloaded. In my case, I use anaconda numpy. (anaconda have it installed already, for normal python, use pip install numpy)
To tell camke where the path is, just take my command as an example:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules \
-D PYTHON2_EXECUTABLE='/home/parallels/anaconda2/bin/python' \
-D PYTHON2_LIBRARY='/home/parallels/anaconda2/lib/python2.7' \
-D PYTHON2_NUMPY_INCLUDE_DIRS='/home/parallels/anaconda2/lib/python2.7/site-packages/numpy/core/include' \
-D BUILD_EXAMPLES=ON ..
for python3,you should (I'm using anaconda python, so I linked everything to anaconda):
cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-3.3.1/modules \
-D PYTHON3_EXECUTABLE='/home/test/SoftWare/anaconda3/bin/python3.6m' \
-D PYTHON_INCLUDE_DIR='/home/test/SoftWare/anaconda3/include/python3.6m' \
-D PYTHON3_LIBRARY='/home/test/SoftWare/anaconda3/lib/libpython3.6m.so' \
-D PYTHON3_NUMPY_INCLUDE_DIRS='/home/test/SoftWare/anaconda3/lib/python3.6/site-packages/numpy/core/include' \
-D PYTHON3_PACKAGES_PATH='/home/test/SoftWare/anaconda3/lib/python3.6/site-packages' ..
One thing to remember!!! before you enter cmake ... 1. clean your build folder, 2. Only camke once! otherwise you can not change ** PYTHON3_LIBRARY: NO**...(this is a bug I think)
I know there might be some useless arguments, but I am tired to try to clean them. Here's a screenshot of my cmake print info.
screenshot of my cmake info
You can clearly see that, only python2 can generate cv2.so. python3 can not! (Python3 wrappers can not be generated).
I came across similar problem. After digging into this a little more I came across a post where it was mentioned that python-numpy package was required. So, I uninstalled the opencv by running the following command in build folder(in your case release folder):
dpkg -r build
Then I removed all the opencv files. I installed python-numpy and python-dev with this command:
sudo apt-get install python-dev python-numpy
Then, after re-running the installation script, import cv2 command in python console doesn't give me any error and is properly imported.
In my case it was a problem with cmake:
sudo apt install software-properties-common
sudo add-apt-repository ppa:george-edison55/cmake-3.x
sudo apt update
If cmake is not yet installed:
sudo apt install cmake
If cmake is already installed:
sudo apt upgrade
For more information, see this link.

Resources