Torch中多GPU运行代码学习
来源:互联网 发布:excel数组 编辑:程序博客网 时间:2024/05/20 22:29
Main.lua
-- Copyright (c) 2014, Facebook, Inc.
-- All rights reserved.
--
-- This source code is licensed under the BSD-style license found in the
-- LICENSE file in the root directory of this source tree. An additional grant
-- of patent rights can be found in the PATENTS file in the same directory.
--
require 'torch'
require 'cutorch'
require 'paths'
require 'xlua'
require 'optim'
require 'nn'
torch.setdefaulttensortype('torch.FloatTensor')
local opts= paths.dofile('opts.lua')
opt = opts.parse(arg)
nClasses = opt.nClasses
paths.dofile('util.lua')
paths.dofile('model.lua')
opt.imageSize = model.imageSizeor opt.imageSize
opt.imageCrop = model.imageCropor opt.imageCrop
print(opt)
cutorch.setDevice(opt.GPU)-- by default, use GPU 1
torch.manualSeed(opt.manualSeed)
print('Saving everything to: ' .. opt.save)
os.execute('mkdir -p ' .. opt.save)
paths.dofile('data.lua')
paths.dofile('train.lua')
paths.dofile('test.lua')
epoch = opt.epochNumber
for i=1,opt.nEpochsdo
train()
test()
epoch = epoch+ 1
end
The training scripts come with several options which can be listed by running the script with the flag --help
th main.lua --help
To run the training, simply run main.lua By default, the script runs 1-GPU AlexNet with the CuDNN backend and 2 data-loader threads.
th main.lua -data [imagenet-folder with train and val folders]
For 2-GPU model parallel AlexNet + CuDNN, you can run it this way:
th main.lua -data [imagenet-folder with train and val folders] -nGPU 2 -backend cudnn -netType alexnet
Similarly, you can switch the backends to 'cunn' to use a different set of CUDA kernels.
You can also alternatively train OverFeat using this following command:
th main.lua -data [imagenet-folder with train and val folders] -netType overfeat
# multi-GPU overfeat (let's say 2-GPU)
th main.lua -data [imagenet-folder with train and val folders] -netType overfeat -nGPU 2
- Torch中多GPU运行代码学习
- torch学习(四) using GPU
- 代码-Torch7-学习torch-tutorials
- torch学习笔记3.3:实现自定义模块(gpu)
- Torch 7 GPU Module
- torch代码学习系列一:age_gender
- 机器学习torch代码训练过程中常见bug解决经验
- torch学习
- 在Docker中运行torch版的neural style
- tensorflow学习笔记(三十一):构建多GPU代码
- Ubuntu+GPU上Debug Torch项目fairseq
- torch学习(一) torch使用
- torch学习笔记
- torch学习笔记
- torch学习资料
- Torch深度学习入门
- Torch学习(二)
- torch学习笔记<一>
- C数组解决魔术师发牌问题
- 【Ubuntu】安装字体
- 多线程编程学习::POSIX 多线程基础(二)
- SpringBoot学习(一)
- Mysql之查询
- Torch中多GPU运行代码学习
- Java手动实现简单 ArrayList
- (五)PipedInputStream与PipedOutputStream
- Hibernate
- 免费领取微软OneDrive网盘5T容量,非扩容!
- hdu4812 D Tree
- HDU 2700 Parity(签到)
- ZooKeeper 分布式安装手册:
- 遍历聚合对象中的元素——迭代器模式(二)