-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First attempt to use more gpus #339
Conversation
This is a deep WIP so far... |
@matze so I tried this: shape = 2048, 4096
image = np.random.normal(1000, 10, size=shape).astype(np.float32)
def generate(num_images=10):
image = np.random.normal(1000, 10, size=shape).astype(np.float32)
for i in range(num_images):
print 'yielding', id(image), i + 1
yield image
print 'yielded', id(image), i + 1
@async
def process(backproject, arch, gpu, result, num_images=10):
try:
inject(generate(num_images=num_images), backproject(result(), arch=arch, gpu=gpu))
finally:
backproject.wait()
def run(num_images=10):
arch = Ufo.ArchGraph()
gpus = arch.get_gpu_nodes()
resources = {}
for i, gpu in enumerate(gpus):
resources[gpu] = (Backproject(image.shape[1] / 2), Result())
futures = []
st = time.time()
for gpu, (bp, result) in resources.iteritems():
futures.append(process(bp, arch, gpu, result, num_images=num_images))
wait(futures)
print 'duration: {} s'.format(time.time() - st)
return zip(*resources.values())[1] But unfortunately I got no speedup plus the memory was not released. |
Even though I call |
And funnily, those |
There is a nasty race condition for me in this example. Waiting for the futures begins before the processes started which results in an |
Actually I have problems to get this running at all. Do you made any changes to either ufo-core or Concert? |
Did you install this branch when you tried? |
Yes, of course. |
Can you re-check? I tried with master and got the same error you mentioned above AttributeError: 'Backproject' object has no attribute 'thread' |
I just logged in, did no changes to |
As I said, it's a race condition. If it starts executing before waiting on the futures begins it should be fine. But I am not sure how to solve this generally at the moment. |
It is not a race condition because when you wait for the futures (if you mean the ones just before the duration printout) you are waiting for the try:
backproject.start() # inside the __call__, backproject.thread exists from now on
while True:
# crunch
finally:
backproject.wait() Try this @async
def process(backproject, arch, gpu, result, num_images=10):
inject(generate(num_images=num_images), backproject(result(), arch=arch, gpu=gpu))
backproject.wait() Does it by any chance say: TypeError: __call__() got an unexpected keyword argument 'gpu' |
No, it never did so because I told you already that I am using the correct branch. After removing the |
Hm, but then I have no idea what the problem is. Especially since for me it works every time. Actually I experienced some random hangings and segfaults but that was very rare and before your final python multithreading fix, now I have no idea if it still happens. |
I release the GIL in the output task now which let's all schedulers run fully in parallel. I haven't checked the memory consumption yet though. |
Should I try? Do I need to update/do smth. special on the ufo server? |
Yeah, try what you wanted to try. I see the speed up and I guess you have to update ufo-core if you don't use a local installation. |
After a fresh pull it doesn't build... EDIT: All OK, |
Nope, it builds on my machine but not on the server... |
I ran it on the server ... |
In /opt/ufo-core:
How did you manage locally? |
I have no idea why it didn't complain in my case. Anyway, I pushed a change that removes that warning, compiled and installed it. Have fun. |
Thanks, I will! |
to UniversalBackprojectArgs for user convenience.
to unify naming with ufo-filters.
i.e. there are no slice consumers.
3f48902
to
acad4df
Compare
This has been around for long enough. |
A collaborative PR for making UFO work on more GPUs from concert.