zoukankan      html  css  js  c++  java
  • Torch 的安装与基本用法

    本文安装仅限 ubuntu 系统。官方文档见:Getting started with Torch

    0. 简介

    • Torch 使用轻量级脚本语言 Lua 及其 C/CUDA 扩展模块实现,底层数值计算通过高效的 OpenMP/SSE/CUDA 加速;

    1. 安装

    进入命令行终端,分别执行下面三行的代码,

    git clone https://github.com/torch/distro.git ~/torch --recursive
    cd ~/torch; bash install-deps;
    ./install.sh

    install.sh脚本会自动将 torch 路径添加进 Path 变量,因此还需执行下述代码以刷新环境变量。

    # On Linux with bash
    source ~/.bashrc
    # On Linux with zsh
    source ~/.zshrc
    # On OSX or in Linux with none of the above.
    source ~/.profile

    2. 安装第三方库

    • $ luarocks list:查看已安装库;
    • $ luarocks install image:安装 image库;
      • $ luarocks list:再次查看是否已安装 image 库;

    3. torch 命令行环境

    在 ubuntu 命令行输入 th以进入 torch 的 repl (read-eval-print loop)环境。

    $ th
    
      ______             __   |  Torch7 
     /_  __/__  ________/ /   |  Scientific computing for Lua. 
      / / / _ / __/ __/ _   |  Type ? for help 
     /_/  \___/_/  \__/_//_/  |  https://github.com/torch 
                              |  http://torch.ch 
    
    • th> os.exit():退出;
  • 相关阅读:
    Subsequence
    【模板】AC自动机(加强版)
    1563: hzwer的跳跳棋(hop)
    P2469 [SDOI2010]星际竞速
    P2746 [USACO5.3]校园网Network of Schools
    Blocks
    Training little cats
    Period
    UVA-3942 Remember the Word
    初学线段树(poj3264+poj2777)
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9421452.html
Copyright © 2011-2022 走看看