torch框架安装linux,Torch的安装配置与使用,如何在Mac OS X和Ubuntu上安装Torch? - pytorch中文网...

安装Torch

官方提供在Mac OS X和Ubuntu 12+上安装Torch:

你可以通过如下三个命令把Torch安装到你的home文件夹中,注意:包比较大,需要耐心等待:

#在终端运行命令没有sudo

git clone https://github.com/torch/distro.git ~/torch --recursive

cd ~/torch; bash install-deps;

./install.sh

第一个脚本安装基本的软件包的依赖关系,要求LuaJIT和Torch。第二脚本安装LuaJIT,luarocks,然后使用luarocks(Lua包管理器)安装核心包像Torch,NN和路径,以及一些其他的包。

该脚本添加到您的路径变量Torch。你只需要一次就可以刷新你的环境变量。安装脚本将检测您当前的shell,并在正确的配置文件中修改路径。

# On Linux with bash

source ~/.bashrc

# On Linux with zsh

source ~/.zshrc

# On OSX or in Linux with none of the above.

source ~/.profile

如果你需要卸载Torch,只需运行命令:

rm -rf ~/torch

如果你想安装Torch的lua 5.2代替LuaJIT,简单地运行:

git clone https://github.com/torch/distro.git ~/torch --recursive

cd ~/torch

# clean old torch installation

./clean.sh

# optional clean command (for older torch versions)

# curl -s https://raw.githubusercontent.com/torch/ezinstall/master/clean-old.sh | bash

# https://github.com/torch/distro : set env to use lua

TORCH_LUA_VERSION=LUA52 ./install.sh

新的软件包,可以使用命令行luarocks安装:

# run luarocks WITHOUT sudo

$ luarocks install image

$ luarocks list

一旦安装好,你就可以用你的命令运行Torch了!

在学习和试验Torch的最简单的方法是启动一个交互式会话(也被称为TorchRead-Eval-Print-Loop或trepl):

$ th

______ __ | Torch7

/_ __/__ ________/ / | Scientific computing for Lua.

/ / / _ \/ __/ __/ _ \ |

/_/ \___/_/ \__/_//_/ | https://github.com/torch

| http://torch.ch

th> torch.Tensor{1,2,3}

1

2

3

[torch.DoubleTensor of dimension 3]

th>

退出交互会话,型^C两控制键和C键,两次,或类型的操作系统。exit()。一旦用户输入了一个完整的表达式,如1 + 2,并点击进入,交互会话将计算表达式并显示其值。

评价写在一个源文件file.lua表达式,写dofile”文件。lua”。

要在非交互式的文件中运行代码,可以将它作为第一个参数传递给TH命令:

$ th file.lua

有不同的方法来运行lua代码和提供选项,类似于那些用于Perl和Ruby程序:

$ th -h

Usage: th [options] [script.lua [arguments]]

Options:

-l name load library name

-e statement execute statement

-h,--help print this help

-a,--async preload async (libuv) and start async repl (BETA)

-g,--globals monitor global variables (print a warning on creation/access)

-gg,--gglobals monitor global variables (throw an error on creation/access)

-x,--gfx start gfx server and load gfx env

-i,--interactive enter the REPL after executing a script

TREPL充满了方便的特性:

tab补齐在嵌套名称空间

打开磁盘文件(打开字符串时)

历史(会话之间保存)

漂亮的打印(表内省和着色)

eval(可以停止)自动打印(可以停止)

每个命令都被提交,时间被报告

不需要“=”打印

简单的帮助:?funcname

自助:?

Shell命令:$ cmd(示例:$ ls)

接下来的步骤

除了这本手册,还有各种其他的资源,可以帮助新用户开始使用Torch,都总结在本列表

该控件提供的教程,演示,包总结和大量有用的信息。

如果你有问题,请加入Torch手用户名单。

原创文章,转载请注明 :Torch的安装配置与使用,如何在Mac OS X和Ubuntu上安装Torch? - pytorch中文网

原文出处: https://ptorch.com/news/32.html

问题交流群 :168117787

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值