我的电脑有两个GPU。这是我第一次使用两个GPU。当我有一个GPU时,我只运行Cuda程序,它只在一个GPU上运行。然而,我不知道如何控制程序使用哪个GPU,以及如何在一个GPU上运行程序。我搜索了互联网
post
说
导出CUDA_VISIBLE_DEVICES=0
这必须在运行程序之前使用。我有两个程序要运行。一个是火炬脚本,另一个是库达脚本。我打开了两个终端,在第一个终端,我使用上面的命令运行火炬程序。之后,在第二终端,我也使用了上面的命令,只将数字从0改为1,然后运行cuda程序。
然而,看到nvidia smi的图片,它显示两个程序被分配给第0个GPU。我想将torch程序(PID 19520)分配给第0个,将cuda程序(PID 20351)分配给第一个GPU。
如何将这两个程序分配给不同的GPU设备?
以下是火炬脚本的设置。(Ubuntu 14.04,nvidia titan gtx x,cuda-7.5)
--[[command line arguments]]--
cmd = torch.CmdLine()
cmd:text()
cmd:text('Train a Recurrent Model for Visual Attention')
cmd:text('Example:')
cmd:text('$> th rnn-visual-attention.lua > results.txt')
cmd:text('Options:')
cmd:option('--learningRate', 0.01, 'learning rate at t=0')
cmd:option('--minLR', 0.00001, 'minimum learning rate')
cmd:option('--saturateEpoch', 800, 'epoch at which linear decayed LR will reach minLR')
cmd:option('--momentum', 0.9, 'momentum')
cmd:option('--maxOutNorm', -1, 'max norm each layers output neuron weights')
cmd:option('--cutoffNorm', -1, 'max l2-norm of contatenation of all gradParam tensors')
cmd:option('--batchSize', 20, 'number of examples per batch')
cmd:option('--cuda', true, 'use CUDA')
cmd:option('--useDevice', 1, 'sets the device (GPU) to use')
cmd:option('--maxEpoch', 2000, 'maximum number of epochs to run')
cmd:option('--maxTries', 100, 'maximum number of epochs to try to find a better local minima for early-stopping')
cmd:option('--transfer', 'ReLU', 'activation function')
cmd:option('--uniform', 0.1, 'initialize parameters using uniform distribution between -uniform and uniform. -1 means default initialization')
cmd:option('--xpPath', '', 'path to a previously saved model')
cmd:option('--progress', false, 'print progress bar')
cmd:option('--silent', false, 'dont print anything to stdout')