From 4c9999505ebd0165987c19eb08800b0c7d0946e6 Mon Sep 17 00:00:00 2001 From: Craig Warren Date: Mon, 11 Mar 2019 14:30:05 +0000 Subject: [PATCH] Updated method for detecting available GPUs. --- gprMax/utilities.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gprMax/utilities.py b/gprMax/utilities.py index 1766265d..4bcb0f69 100644 --- a/gprMax/utilities.py +++ b/gprMax/utilities.py @@ -370,7 +370,7 @@ def detect_check_gpus(deviceIDs): """Get information about Nvidia GPU(s). Args: - deviceIDs (list): List of device IDs. + deviceIDs (list): List of integers of device IDs. Returns: gpus (list): Detected GPU(s) object(s). @@ -387,8 +387,11 @@ def detect_check_gpus(deviceIDs): raise GeneralError('No NVIDIA CUDA-Enabled GPUs detected (https://developer.nvidia.com/cuda-gpus)') # Get list of available GPU device IDs - deviceIDsavail = os.environ.get('CUDA_VISIBLE_DEVICES') - deviceIDsavail = [int(s) for s in deviceIDsavail.split(',')] + if 'CUDA_VISIBLE_DEVICES' in os.environ: + deviceIDsavail = os.environ.get('CUDA_VISIBLE_DEVICES') + deviceIDsavail = [int(s) for s in deviceIDsavail.split(',')] + else: + deviceIDsavail = range(drv.Device.count()) # Print information about all detected GPUs gpus = []