File tree 1 file changed +16
-5
lines changed
Filter options
1 file changed +16
-5
lines changed
Original file line number Diff line number Diff line change 25
25
logger = logging .getLogger ('workflow' )
26
26
27
27
# GPU stuff
28
- import GPUtil
29
28
import json
30
29
import os
31
30
@@ -166,17 +165,24 @@ def __init__(self, plugin_args=None):
166
165
167
166
168
167
#form a GPU queue first
169
- gpus = GPUtil .getGPUs ()
168
+ gpus = []
169
+ try :
170
+ import GPUtil
171
+ ngpus = GPUtil .getGPUs ()
172
+ gpus = list (range (len (ngpus )))
173
+ except ImportError :
174
+ gpus = list (range (self .n_gpus ))
175
+
170
176
self .gpu_q = {}
171
177
172
178
#initialize the queue, set all slots free
173
179
slotno = 0
174
- for gpu in gpus :
180
+ for gpu in range ( len ( gpus )) :
175
181
temp = {}
176
182
for ngp in range (self .n_gpu_proc ):
177
183
slotno += 1
178
184
temp .update ({slotno :'free' })
179
- self .gpu_q .update ({ gpu . id : temp })
185
+ self .gpu_q .update ({ gpu : temp })
180
186
181
187
182
188
# Instantiate different thread pools for non-daemon processes
@@ -206,7 +212,12 @@ def _clear_task(self, taskid):
206
212
207
213
208
214
def gpu_count (self ):
209
- return len (GPUtil .getGPUs ())
215
+ ngpus = 1
216
+ try :
217
+ import GPUtil
218
+ return len (GPUtil .getGPUs ())
219
+ except ImportError :
220
+ return ngpus
210
221
211
222
def gpu_has_free_slot (self ):
212
223
#if a GPU has free slot, return True,its device-ID and the slot no.
You can’t perform that action at this time.
0 commit comments