[PYTHON] Introduction of caffe using pyenv

2016.3.22 Introduce all the libraries that are often used for machine learning. The environment is Ubuntu 14.04 LTS (because this is the recommended environment for caffe and chainer)

pyenv

git clone https://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc

python

pyenv install anaconda-2.1.0
pyenv rehash
pyenv global anaconda-2.1.0
echo 'export PATH="$PYENV_ROOT/versions/anaconda-2.1.0/bin/:$PATH"' >> ~/.bashrc
source ~/.bashrc

This time, I used anaconda-2.1.0 recommended by Caffe. Also, since anaconda is a numerical calculation package, it is convenient because numpy, scipy, and scikit-learn are included from the time of introduction.

Next, we introduced Caffe, Chainer, TensorFlow that we usually use from the deep learning library. Caffe

## cuda install 
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.0-28_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1404_7.0-28_amd64.deb
sudo apt-get update
sudo apt-get install cuda
sudo apt-get install libatlas-base-dev
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler g++-4.6

--Caffe (main body)

## caffe
cd $HOME
git clone https://github.com/BVLC/caffe.git ~/caffe
cd caffe
cp Makefile.config.example Makefile.config
### ※
echo "CPU_ONLY := 1" >> Makefile.config
echo "CXX := /usr/bin/g++-4.6" >> Makefile.config

I've finished putting it all in, so I'll do an execution test

make -j4 all
make -j4 test
make -j4 runtest

I want to use caffe with python, so I will introduce pycaffe.

##pycaffe
pip install -r ~/caffe/python/requirements.txt
sudo apt-get install python-dev python-pip python-numpy python-skimage
sudo apt-get install --no-install-recommends libboost-all-dev
echo "export PYTHONPATH=~caffe/python/:$PYTHONPATH" >> ~/.bashrc
source ~/.bashrc
make pycaffe
import caffe

If there are no particular errors, it's okay. It should be noted that here

make pycaffe
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
touch python/caffe/proto/__init__.py
PROTOC (python) src/caffe/proto/caffe.proto

>>> import caffe
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/yuki/caffe/python/caffe/__init__.py", line 1, in 
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
  File "/home/yuki/caffe/python/caffe/pycaffe.py", line 13, in 
    from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: /home/yuki/.pyenv/versions/anaconda-2.1.0/bin/../lib/libm.so.6: version `GLIBC_2.15' not found (required by /usr/lib/x86_64-linux-gnu/libxvidcore.so.4)

If you get an error like this, for the time being

/home/yuki/.pyenv/versions/anaconda-2.1.0/bin/../lib/libm.so.6

If you delete this file, the library will be loaded (not completely solved).

After all it is difficult to build an environment for caffe (´ ・ ω ・ `)

chainer

pip install chainer

That's it! !! It's good

Tensorflow For some reason the library is not loaded and I have a hard time [TensorFlow-Download and Setup] (https://www.tensorflow.org/versions/r0.7/get_started/os_setup.html#pip-installation)

sudo apt-get install python-pip python-dev
#CPU
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl

Recommended Posts

Introduction of caffe using pyenv
Introduction of Python
Introduction of scikit-optimize
Introduction of cymel
Introduction of Python
An amateur tried Deep Learning using Caffe (Introduction)
Summary of pyenv usage
Introduction of ferenOS 1 (installation)
Introduction of Virtualenv wrapper
Example of using lambda
Mechanism of pyenv and virtualenv
Implementation of TF-IDF using gensim
[CentOS7] Install anaconda using pyenv
[I tried using Pythonista 3] Introduction
Introduction of activities applying Python
Change python version using pyenv
python: Basics of using scikit-learn ①
Coexistence of pyenv and autojump
Introduction to discord.py (3) Using voice
Introduction and tips of mlflow.Tracking
List of libraries to install when installing Python using Pyenv
A memorandum of using eigen3
Vertical Tower of Pisa using OpenCV
Raise the version of pyenv itself
Introduction and Implementation of JoCoR-Loss (CVPR2020)
Image capture of firefox using python
Judgment of backlit image using OpenCV
Calculation of normal vector using convolution
Introduction and implementation of activation function
Introducing Python using pyenv on Ubuntu 20.04
Removal of haze using Python detailEnhanceFilter
Visualization of mixed matrices using sklearn.metrics.ConfusionMatrixDisplay
Collective measurement of Volume using FSL
I tried using GrabCut of OpenCV
Introduction of data-driven controller design method
Environment construction memo of pyenv + conda
Using Cloud Storage from Python3 (Introduction)
Notes on installing Python using PyEnv
Introduction of pipenv (also create requirements.txt)
Limitation of default dict using typing
Implementation of desktop notifications using Python
Introduction of ferenOS 3 (package update, installation)
Install Python on CentOS using Pyenv
Introduction of python drawing package pygal
Recommendation of data analysis using MessagePack
Notation of template matching using convolution
Image recognition of fruits using VGG16
Record of Python introduction for newcomers
Install Python on CentOS using pyenv
(Beginner) Notes on using pyenv on Mac