机器学习开源框架系列:Torch:2:MacOS上安装Torch7
发布日期:2021-06-30 20:21:04
浏览次数:2
分类:技术文章
本文共 5685 字,大约阅读时间需要 18 分钟。
由于希望确认一下2015年和2016年的两篇论文相关的内容,这篇文章以官方提示的安装方式为例进行安装方法的memo。基本信息
项目 | 说明 |
---|---|
官方网站 | http://torch.ch/ |
开源/闭源 | 开源 |
License类别 | BSD License |
代码管理地址 | https://github.com/torch/torch7 |
开发语言 | C,Lua |
支持平台 | 由于使用C和Lua,Torch可以支持多种操作系统诸如Linux/MacOSX/iOS/Android等 |
当前版本 | 7.0 (2017/02/27) |
其他基本信息可参看:
安装方式
步骤1: 下载git仓库
执行命令:git clone https://github.com/torch/distro.git ~/torch --recursive
liumiaocn:~ liumiao$ git clone https://github.com/torch/distro.git ~/torch --recursiveCloning into '/Users/liumiao/torch'...remote: Enumerating objects: 1601, done....省略Submodule path 'pkg/xlua': checked out '41308fe696bf8b0892f4ad4f9857d12a87a3f75e'liumiaocn:~ liumiao$ du -k torch |tail -n179120 torchliumiaocn:~ liumiao$
步骤2: 安装依赖
执行命令:cd ~/torch; bash install-deps;
liumiaocn:~ liumiao$ cd torch/liumiaocn:torch liumiao$ lsCMakeLists.txt clean.bat extra install.sh travis_cuda_install.shLICENSE.md clean.sh install-deps pkg uninstall.batREADME.md cmake install-deps.bat test.bat update.shadmin exe install.bat test.sh win-filesliumiaocn:torch liumiao$ view install-depsliumiaocn:torch liumiao$ which bash/bin/bashliumiaocn:torch liumiao$ bash install-deps...省略Emacs Lisp files have been installed to: /usr/local/share/emacs/site-lisp/git==> cmakeEmacs Lisp files have been installed to: /usr/local/share/emacs/site-lisp/cmakeliumiaocn:torch liumiao$
torch提供了上述的脚本用于直接下载相关的依赖,实际上确认一下可以看到对于不同操作系统的支持,比如此处是使用macOS的方式, 可以看到如果没有安装brew,它还会替你安装一个,然后通过brew来完成所需要的依赖的安装
79 if [[ `uname` == 'Darwin' ]]; then 80 # GCC? 81 if [[ `which gcc` == '' ]]; then 82 echo "MacOS doesn't come with GCC: please install XCode and the command line tools." 83 exit 1 84 fi 85 86 # Install Homebrew (pkg manager): 87 if [[ `which brew` == '' ]]; then 88 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 89 fi 90 91 # Install dependencies: 92 brew update 93 brew install git readline cmake wget 94 brew install libjpeg imagemagick zeromq graphicsmagick openssl 95 brew link readline --force 96 brew cask install xquartz 97 brew list -1 | grep -q "^gnuplot\$" && brew remove gnuplot 98 brew install gnuplot --with-wxmac --with-cairo --with-pdflib-lite --with-x11 --without-lua 99 brew install qt || true
步骤3: 安装torch
执行命令:./install.sh
liumiaocn:torch liumiao$ pwd/Users/liumiao/torchliumiaocn:torch liumiao$ lsCMakeLists.txt clean.bat extra install.sh travis_cuda_install.shLICENSE.md clean.sh install-deps pkg uninstall.batREADME.md cmake install-deps.bat test.bat update.shadmin exe install.bat test.sh win-filesliumiaocn:torch liumiao$ ./install.sh Prefix set to /Users/liumiao/torch/installInstalling Lua version: LUAJIT21CMake Warning (dev) in CMakeLists.txt:...省略-- Configuring done-- Generating done-- Build files have been written to: /Users/liumiao/torch/pkg/torch/buildScanning dependencies of target luaTScanning dependencies of target TH[ 2%] Building C object lib/luaT/CMakeFiles/luaT.dir/luaT.c.o...省略Do you want to automatically prepend the Torch install locationto PATH and LD_LIBRARY_PATH in your /Users/liumiao/.bashrc? (yes/no)[yes] >>> yesliumiaocn:torch liumiao$ cat ~/.bashrc |tail -n1. /Users/liumiao/torch/install/bin/torch-activateliumiaocn:torch liumiao$
安装确认
步骤1: 读取环境变量
执行命令:source ~/.bashrc
liumiaocn:torch liumiao$ source ~/.bashrc liumiaocn:torch liumiao$ which th/Users/liumiao/torch/install/bin/thliumiaocn:torch liumiao$
步骤2: 确认luagit
Torch7希望自己是自包含的,这里面luagit起到了一个重要作用,luajit会同时一同被安装,所以需要进行确认
liumiaocn:torch liumiao$ which luajit/Users/liumiao/torch/install/bin/luajitliumiaocn:torch liumiao$ luajit -vLuaJIT 2.1.0-beta1 -- Copyright (C) 2005-2015 Mike Pall. http://luajit.org/ _____ _ |_ _| | | | | ___ _ __ ___| |__ | |/ _ \| '__/ __| '_ \ | | (_) | | | (__| | | | \_/\___/|_| \___|_| |_|liumiaocn:torch liumiao$
使用此版本的luajit进行动作确认
liumiaocn:torch liumiao$ luajitLuaJIT 2.1.0-beta1 -- Copyright (C) 2005-2015 Mike Pall. http://luajit.org/ _____ _ |_ _| | | | | ___ _ __ ___| |__ | |/ _ \| '__/ __| '_ \ | | (_) | | | (__| | | | \_/\___/|_| \___|_| |_|JIT: ON SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc sink fuseth> print "Hello LiuMiao"Hello LiuMiaoth>
可以看到Torch7下的luajit确实很小
liumiaocn:torch liumiao$ which luajit/Users/liumiao/torch/install/bin/luajitliumiaocn:torch liumiao$ du -k /Users/liumiao/torch/install/bin/luajit680 /Users/liumiao/torch/install/bin/luajitliumiaocn:torch liumiao$
步骤3: 确认luarocks
除此之外,luarocks作为Lua的包管理的工具也非常重要,确认其版本以及是否能够进行正常操作,后续会通过luarocks install来安装所需的依赖
liumiaocn:torch liumiao$ luarocksLuaRocks 2.3.0, a module deployment system for Lua...省略CONFIGURATION Lua version: 5.1 Configuration files: System: /Users/liumiao/torch/install/etc/luarocks/config.lua (ok) User : /Users/liumiao/.luarocks/config-5.1.lua (not found) Rocks trees in use: /Users/liumiao/.luarocks /Users/liumiao/torch/installliumiaocn:torch liumiao$ liumiaocn:torch liumiao$ luarocks list nn...省略nn scm-1 (installed) - /Users/liumiao/torch/install/lib/luarocks/rocksnngraph scm-1 (installed) - /Users/liumiao/torch/install/lib/luarocks/rocksnnx 0.1-1 (installed) - /Users/liumiao/torch/install/lib/luarocks/rocksliumiaocn:torch liumiao$
步骤4: 确认th
Torch可以通过交互式的th进行操作,确认其是否能够正常进入
liumiaocn:torch liumiao$ th ______ __ | Torch7 /_ __/__ ________/ / | Scientific computing for Lua. / / / _ \/ __/ __/ _ \ | Type ? for help /_/ \___/_/ \__/_//_/ | https://github.com/torch | http://torch.ch th>
总结
这篇文章介绍了Torch官方的安装方式,并以MacOS为例进行了memo。
参考内容
http://torch.ch/docs/getting-started.html
转载地址:https://liumiaocn.blog.csdn.net/article/details/109848433 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
第一次来,支持一个
[***.219.124.196]2024年05月02日 11时37分24秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Linux png转jpg (convert命令)
2019-04-30
NAS (Network Attached Storage 网络附属存储)
2019-04-30
Ubuntu更新后终端中字体的颜色全是白色
2019-04-30
vscode git
2019-04-30
基于MATLAB的二进制数字调制与解调信号的仿真——2FSK
2019-04-30
基于MATLAB的二进制数字调制与解调信号的仿真——2PSK
2019-04-30
基于MATLAB的模拟调制信号与解调的仿真——AM
2019-04-30
基于MATLAB的模拟调制信号与解调的仿真——DSB
2019-04-30
基于MATLAB的模拟调制信号与解调的仿真——SSB
2019-04-30
操作系统实验之生产者和消费者程序
2019-04-30
操作系统实验之猴子过桥问题的模拟程序
2019-04-30
POJ - 3067 Japan (树状数组 思维)
2019-04-30
POJ - 2352 Stars (树状数组 入门题)
2019-04-30
HDU - 1166 敌兵布阵 (树状数组模板题/线段树模板题)
2019-04-30
CodeForces - 761C Dasha and Password (思维 暴力)
2019-04-30
POJ - 2481 Cows (树状数组 入门题)
2019-04-30
ACM-ICPC 2018 焦作赛区网络预赛 I. Save the Room
2019-04-30
CodeForces - 987C Three displays (暴力/dp)
2019-04-30