参考
https://caffe2.ai/docs/tutorials
运行环境
- OS: debian8_x86_64
学习文档安装
下载教程源码
1 | git clone --recursive https://github.com/caffe2/tutorials caffe2_tutorials |
安装依赖
运行教程,需要一些第三方库,包括 ipython-notebooks 和 matplotlib
如果你是Anaconda用户, 用conda install
代替pip install
1 | pip install -U pip setuptools |
卸载ipython并且把配置文件删除1
apt purge ipython
再次pip 报错1
networkx 2.1 has requirement decorator>=4.1.0, but you'll have decorator 3.4.0 which is incompatible.
卸载decorator1
pip uninstall decorator
再次pip
输出末尾显示自动装好的decorator 4.3.01
2Installing collected packages: decorator
Successfully installed decorator-4.3.0
回到教程
安装zeromq
有些教程用到的包不在pip里面:zeromq
Mac用户运行: brew install unzip zeromq
Ubuntu用户运行 : apt-get install unzip zeromq
Centos用户运行 : yum install unzip zeromq
apt并没有找到zeromq
http://zeromq.org/area:download
deb安装
编译安装
1 | wget https://github.com/zeromq/libzmq/releases/download/v4.2.3/zeromq-4.2.3.tar.gz |
deb安装1
2wget http://ftp.halifax.rwth-aachen.de/opensuse/repositories/network:/messaging:/zeromq:/release-stable/Debian_8.0/amd64/libzmq5_4.2.5_amd64.deb
dpkg -i libzmq5_4.2.5_amd64.deb
依赖报错1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18dpkg -i libzmq5_4.2.5_amd64.deb
Selecting previously unselected package libzmq5:amd64.
(Reading database ... 73719 files and directories currently installed.)
Preparing to unpack libzmq5_4.2.5_amd64.deb ...
Unpacking libzmq5:amd64 (4.2.5) ...
dpkg: dependency problems prevent configuration of libzmq5:amd64:
libzmq5:amd64 depends on libnorm1; however:
Package libnorm1 is not installed.
libzmq5:amd64 depends on libpgm-5.1-0 (>= 5.1.116~dfsg); however:
Package libpgm-5.1-0 is not installed.
libzmq5:amd64 depends on libsodium13 (>= 0.6.0); however:
Package libsodium13 is not installed.
dpkg: error processing package libzmq5:amd64 (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
libzmq5:amd64
自动修复依赖apt -f install
但是还是有个叫libnorm1的包找不到
还是编译安装吧 =。=
然后运行在 caffe2_tutorials
目录中shell 脚本1
./start_ipython_notebook.sh
输出1
2
3
4
5
6root@debian:~/caffe2_tutorials# ./start_ipython_notebook.sh
[TerminalIPythonApp] WARNING | Subcommand `ipython notebook` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter notebook` in the future
[I 09:15:27.557 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 09:15:27.589 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[C 09:15:27.658 NotebookApp] Running as root is not recommended. Use --allow-root to bypass.
看下这个脚本内容1
2
3
4
5
6
7
8
9
10root@debian:~/caffe2_tutorials# cat start_ipython_notebook.sh
# This script simply starts the ipython notebook and allows all network machines
# to access it.
# Use the following command for very verbose prints.
# GLOG_logtostderr=1 GLOG_v=1 ipython notebook --ip='*'
# Use the following command for a normal run.
ipython notebook --ip='*'
allow root1
ipython notebook --ip='*' --allow-root
然后就启动了notebook server1
2
3
4
5
6
7
8
9
10
11
12
13
14root@debian:~/caffe2_tutorials# ipython notebook --ip='*' --allow-root
[TerminalIPythonApp] WARNING | Subcommand `ipython notebook` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter notebook` in the future
[W 09:21:04.119 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 09:21:04.149 NotebookApp] Serving notebooks from local directory: /root/caffe2_tutorials
[I 09:21:04.149 NotebookApp] 0 active kernels
[I 09:21:04.149 NotebookApp] The Jupyter Notebook is running at:
[I 09:21:04.149 NotebookApp] http://[all ip addresses on your system]:8888/?token=def4b7ebc92506308fd9221242fc47fcbfd2933744a15aa3
[I 09:21:04.149 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 09:21:04.151 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=def4b7ebc92506308fd9221242fc47fcbfd2933744a15aa3
或者你可以运行jupyter notebook
,当你在浏览器打开本地jupyter server(默认是http://localhost:8888), 浏览Caffe2的仓库,在caffe2_tutorials 目录中查看教程. 用这种方式打开notebook会启动他们的交互功能,就像运行shell 脚本一样。该脚本具有设置PYTHONPATH
环境变量的附加功能。