torch学习笔记1--Ubuntu安装torch

机器学习主流的框架有caffe,torch,TensorFlow,Lasagne,在不同需求下甚至可能需要全部都学习一遍。

由于自己需要完成一个复杂的模型,TensorFlow开源不完全,caffe太复杂,而Lasagne感觉也有点麻烦,所以选择使用Torch完成自己的模型自己的层。

brew uninstall zmq
cd ~/torch; ./install.sh
curl -s https://raw.githubusercontent.com/torch/ezinstall/master/clean-old.sh | bash
curl -sk https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash
rm /usr/local/include/zmq.h
curl -sk https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash
rm -rf ~/torch/
git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch; ./install.sh
source ~/.profile
brew link --overwrite --dry-run zeromq
brew link --overwrite zeromq
luarocks install lzmq
luarocks install image 
luarocks list

在最后一步如果出现

Warning: Failed loading manifest for /root/.luarocks/lib/luarocks/rocks: /root/.luarocks/lib/luarocks/rocks/manifest: No such file or directory

可以使用解决

mkdir -p ~/.luarocks/lib/luarocks/rocks
luarocks-admin make-manifest --local-tree --tree=$HOME/.luarocks

torch安装之后还只是console编辑方式,所以安装itorch notebook来进行代码编辑。

itorch notebook是基于ipython notebook,只是在已有的基础之上增加torch kernel。

sudo apt-get install python-pip
sudo apt-get install ipython
sudo apt-get install ipython-notebook
ipython notebook
pip install jupyter

itorch安装的命令集,下载的第一个文件文件需要FQ

#!/bin/sh
# Install Python prerequisites on NVIDIA Jetson TK1 for iTorch
# This is for https://github.com/facebook/iTorch
# L4T 21.3, Torch 7 (http://torch.ch)
# Python 2.7 or greater must be installed before running this script
# Torch 7 should already be installed before running this script
# iPython is loaded using pip, as repository version is 1.x version, > 2.0 is needed
# Need to compile from source as repository version libzmq3-dev is not the correct revision
wget http://download.zeromq.org/zeromq-4.0.5.tar.gz
tar xzvf zeromq-4.0.5.tar.gz
cd zeromq-4.0.5
./configure
make
sudo make install
cd ..

sudo apt-get install python-dev -y
sudo apt-get install python-pip -y
sudo pip install ipython
sudo apt-get install python-zmq -y
sudo apt-get install python-markupsafe -y
sudo apt-get install python-jsonschema -y
sudo pip install jinja2
sudo pip install tornado
sudo luarocks install luacrypto 
sudo luarocks install env
sudo luarocks install lzmq
sudo luarocks install lbase64
sudo luarocks install uuid
# add some decoders for iTorch audio and video
sudo apt-get install gstreamer1.0-libav -y
# Install iTorch
git clone https://github.com/facebook/iTorch.git ~/iTorch --recursive
cd ~/iTorch 
sudo env "PATH=$PATH" luarocks make 
sudo chown -R $USER $(dirname $(ipython locate profile))
zeromq安装的时候可能会需要安装libsodium
#!/bin/bash
sudo add-apt-repository ppa:chris-lea/libsodium;
sudo echo "deb http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main" >> /etc/apt/sources.list;
sudo echo "deb-src http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main" >> /etc/apt/sources.list;
sudo apt-get update && sudo apt-get install libsodium-dev;

  从github上面git时有的时候不挂代理会更好。

这个时候我们就能愉快的玩耍了。

使用命令th、itorch、itorch notebook皆能使用。

posted @ 2017-03-01 13:57  难解是非题  阅读(2917)  评论(1编辑  收藏  举报