From be7de4a18bdfd89fbd1fdc852d170f68cdc65ba4 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 19 Jun 2020 20:25:22 +0200 Subject: Bugfix for GL interop context initialization Following PyOpenCL documentation This caused startup to fail when using via VirtualGL on a dual-GPU HPC node. --- simulation.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/simulation.py b/simulation.py index 535310f..5ebe9f6 100644 --- a/simulation.py +++ b/simulation.py @@ -153,8 +153,17 @@ class Lattice: self.platform = cl.get_platforms()[platform] if opengl: - self.context = cl.Context( - properties=[(cl.context_properties.PLATFORM, self.platform)] + get_gl_sharing_context_properties()) + try: + self.context = cl.Context( + properties = [ + (cl.context_properties.PLATFORM, self.platform) + ] + get_gl_sharing_context_properties()) + except: + self.context = cl.Context( + properties = [ + (cl.context_properties.PLATFORM, self.platform) + ] + get_gl_sharing_context_properties(), + devices = [ self.platform.get_devices()[0] ]) else: self.context = cl.Context( properties=[(cl.context_properties.PLATFORM, self.platform)]) -- cgit v1.2.3