From e46056a80857860a923d6577741a1de987bd804f Mon Sep 17 00:00:00 2001 From: Stan Seibert Date: Thu, 31 Jan 2013 16:13:58 -0500 Subject: Do not automatically initialize pycuda before forking the camera process. This causes weird segfaults on Macs, and is probably a source of random crashing on other processes. Also call pygame.init() explicitly in the new process for good measure. --- chroma/camera.py | 4 +++- chroma/gpu/tools.py | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/chroma/camera.py b/chroma/camera.py index f938bd6..0d3e225 100644 --- a/chroma/camera.py +++ b/chroma/camera.py @@ -58,7 +58,7 @@ def encode_movie(dir): class Camera(multiprocessing.Process): "The camera class is used to render a Geometry object." def __init__(self, geometry, size=(800,600), device_id=None): - multiprocessing.Process.__init__(self) + super(Camera, self).__init__() self.geometry = geometry self.device_id = device_id self.size = size @@ -622,6 +622,7 @@ class Camera(multiprocessing.Process): return def run(self): + pygame.init() self.window = pygame.display.set_mode(self.size) self.screen = pygame.Surface(self.size, pygame.SRCALPHA) pygame.display.set_caption('') @@ -825,3 +826,4 @@ def view(obj, size=(800,600), **camera_kwargs): geometry = create_geometry_from_obj(obj) camera = Camera(geometry, size, **camera_kwargs) camera.start() + camera.join() diff --git a/chroma/gpu/tools.py b/chroma/gpu/tools.py index 98c7e6a..8bf5d81 100644 --- a/chroma/gpu/tools.py +++ b/chroma/gpu/tools.py @@ -8,8 +8,6 @@ from pycuda import gpuarray as ga from chroma.cuda import srcdir -cuda.init() - # standard nvcc options cuda_options = ('--use_fast_math',)#, '--ptxas-options=-v'] -- cgit