Torch Cuda - 在两个 GPU 内核上生成两个进程 [英] Torch Cuda - Generates two processes on both GPU cores

查看:46
本文介绍了Torch Cuda - 在两个 GPU 内核上生成两个进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我跑步时;

require 'cutorch'

在 lua 中,它自动将两个进程分配给我 GPU 中的两个内核.例如,我在 nvidia-smi;

in lua it automatically allocates two processes to two of the cores in my GPU. For example I get the following output in nvidia-smi;

---------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0                  Not Supported                                         |
|    1      6091    C   /home/msmith/torch/install/bin/qlua             98MiB |
|    2      6091    C   /home/msmith/torch/install/bin/qlua             99MiB |
+-----------------------------------------------------------------------------+

我希望能够控制进程在哪个 GPU 上进行.我试过了;

I would like to be able to control which GPU the process goes on. I have tried;

cutorch.setDevice(<Device Number>)

但这只会在 GPU 上创建更多进程.

but this just creates more processes on the GPU.

谢谢.

推荐答案

您可以使用 CUDA_VISIBLE_DEVICES 环境变量控制您的进程在启动之前在哪个 GPU 上运行,例如只在 CPU 0 上运行:

You can control which GPU your process will run on before launching it using the CUDA_VISIBLE_DEVICES environment variable, e.g. to run only on CPU 0:

export CUDA_VISIBLE_DEVICES=0
luajit your-script.lua

这篇关于Torch Cuda - 在两个 GPU 内核上生成两个进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆