Tested on Ubuntu 14.04.
Install desired version of python 3 (e.g. 3.5.1). Make sure to use the --enable-shared
flag to generate python shared libraries, which will later be linked to.
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.5.1
Go to a directory where we will do all the following operations. Set that directory to use the version of python that was just installed.
pyenv local 3.5.1
Get pip
for the new installation of python.
wget https://bootstrap.pypa.io/get-pip.py; python get-pip.py; rm get-pip.py
We need to build boost from source since the one from the package manager doesn't support python 3.5 (as of now). Download one of the recent versions of boost from here (I used boost 1.60.0).
If you are using CUDA, you might run into a compiler error involving nvcc
, in which case this patch might solve it.
Build and install boost, telling it to use the python from pyenv.
./bootstrap.sh --with-python=~/.pyenv/versions/3.5.1/bin/python3.5
./b2
# installs to /usr/local/ by default
sudo ./b2 install
The instructions are mostly the same as the official installation instructions except for a few modifications specified below.
First, install the usual system dependencies as described in here.
Then, install the usual python dependecies using pip
, but first update the requirements.txt
file to use protobuf 3.0 alpha. Replace the protobuf line with this one:
pip install protobuf==3.0.0-alpha-3
Install all the requirements as usual:
for req in $(cat requirements.txt); do pip install $req; done
When using cmake
, make sure to specify the python from pyenv that you want to use, e.g.
cmake -DPYTHON_INCLUDE_DIR=~/.pyenv/versions/3.5.1/include/python3.5m -DPYTHON_INCLUDE_DIR2=~/.pyenv/versions/3.5.1/include/python3.5m -DPYTHON_LIBRARY=~/.pyenv/versions/3.5.1/lib/libpython3.so -Dpython_version=3 ../caffe
You can also use
python-config
command, in pyenv.e.g.
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:$(python-config --prefix)/include"