From b86bcac91f55de559a175a99974eab4b8481cb89 Mon Sep 17 00:00:00 2001
From: David Keitel <david.keitel@ligo.org>
Date: Fri, 12 Jan 2018 19:49:16 +0000
Subject: [PATCH] GPU device selection: default when no env variable set

---
 pyfstat/tcw_fstat_map_funcs.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/pyfstat/tcw_fstat_map_funcs.py b/pyfstat/tcw_fstat_map_funcs.py
index 09b9e28..b054d20 100644
--- a/pyfstat/tcw_fstat_map_funcs.py
+++ b/pyfstat/tcw_fstat_map_funcs.py
@@ -129,7 +129,10 @@ def init_transient_fstat_map_features ( ):
         for n, devn in enumerate(devices):
             logging.debug('device {} model: {}, RAM: {}MB'.format(n,devn.name(),devn.total_memory()/(2.**20) ))
 
-        devnum = int(os.environ['CUDA_DEVICE'])
+        if 'CUDA_DEVICE' in os.environ:
+            devnum = int(os.environ['CUDA_DEVICE'])
+        else:
+            devnum = 0
         devn = drv.Device(devnum)
         logging.info('Choosing CUDA device {}, of {} devices present: {}... (Can be changed through environment variable $CUDA_DEVICE.)'.format(devnum,num_gpus,devn.name()))
         logging.debug('Available GPU memory: {}/{} MB free'.format(drv.mem_get_info()[0]/(2.**20),drv.mem_get_info()[1]/(2.**20)))
-- 
GitLab