Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Torch Cuda - Generates two processes on both GPU cores

Tags:

torch

luajit

When I run;

require 'cutorch'

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 |
+-----------------------------------------------------------------------------+

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

cutorch.setDevice(<Device Number>)

but this just creates more processes on the GPU.

Thanks.

like image 493
mattdns Avatar asked Dec 01 '25 03:12

mattdns


1 Answers

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
like image 132
mbrenon Avatar answered Dec 02 '25 22:12

mbrenon