Device management

The device module selects a GPU from the pool of available GPUs. It allocates a CUDA context on that device, which will remain active till the program exits. Diagnostic information is logged about CUDA driver and runtime versions, and GPU capabilities.

halmd.utility.device.gpu may be used to query whether the GPU is being used:

local device = require("halmd.utility.device")
if device.gpu then
    -- using GPU
    -- using host

To select a specific GPU, you may use the nvlock tool:

CUDA_VISIBLE_DEVICES=0 nvlock halmd liquid.lua

nvlock will lock the CUDA device for other processes using nvlock, similar to compute prohibitive mode. This allows scheduling one process per GPU.


The nvlock tool is broken with recent NVIDIA drivers, e.g., later than version 346.


Ordinal number of the CUDA device.