Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 54490f9

Browse filesBrowse files
committed
try to use GPUtil only if available, otherwise use one GPU
1 parent 8fc3799 commit 54490f9
Copy full SHA for 54490f9

File tree

1 file changed

+16
-5
lines changed
Filter options

1 file changed

+16
-5
lines changed

‎nipype/pipeline/plugins/multiproc.py

Copy file name to clipboardExpand all lines: nipype/pipeline/plugins/multiproc.py
+16-5Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
logger = logging.getLogger('workflow')
2626

2727
# GPU stuff
28-
import GPUtil
2928
import json
3029
import os
3130

@@ -166,17 +165,24 @@ def __init__(self, plugin_args=None):
166165

167166

168167
#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+
170176
self.gpu_q={}
171177

172178
#initialize the queue, set all slots free
173179
slotno=0
174-
for gpu in gpus:
180+
for gpu in range(len(gpus)):
175181
temp={}
176182
for ngp in range(self.n_gpu_proc):
177183
slotno +=1
178184
temp.update({slotno:'free'})
179-
self.gpu_q.update({ gpu.id: temp })
185+
self.gpu_q.update({ gpu: temp })
180186

181187

182188
# Instantiate different thread pools for non-daemon processes
@@ -206,7 +212,12 @@ def _clear_task(self, taskid):
206212

207213

208214
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
210221

211222
def gpu_has_free_slot(self):
212223
#if a GPU has free slot, return True,its device-ID and the slot no.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.