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安裝的命令集,下載的第一個文件文件需要翻牆

#!/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皆能使用。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM