Keith Brown
2015-12-03 20:07:44 UTC
I have several GPUs and I want to distribute my tasks to each GPU. I
would like to use multiprocessing.Pool() to accomplish it
import random
import pycuda.gpuarray as gpuarray
import atexit
import pycuda.driver as cuda
import pycuda.autoinit as autoinit
import time
import numpy as np
import skcuda.linalg as linalg
import skcuda
import multiprocessing as mp
import pycuda.driver as drv
def my_proc(n):
drv.init()
dev = drv.Device(n)
ctx = dev.make_context()
atexit.register(ctx.pop)
linalg.init()
a=np.ones((185,185)).astype(np.float32)
a_gpu = gpuarray.to_gpu(a)
c_gpu = linalg.dot(a_gpu,a_gpu)
return c_gpu.get()
r=[]
Pool=mp.Pool(10)
for i in range(1000):
Pool.apply_async(my_proc,(random.randint(0,1),))
I keep getting
pycuda._driver.LogicError: cuCtxPopCurrent failed: invalid device context
Is there somthing I should be doing?
would like to use multiprocessing.Pool() to accomplish it
import random
import pycuda.gpuarray as gpuarray
import atexit
import pycuda.driver as cuda
import pycuda.autoinit as autoinit
import time
import numpy as np
import skcuda.linalg as linalg
import skcuda
import multiprocessing as mp
import pycuda.driver as drv
def my_proc(n):
drv.init()
dev = drv.Device(n)
ctx = dev.make_context()
atexit.register(ctx.pop)
linalg.init()
a=np.ones((185,185)).astype(np.float32)
a_gpu = gpuarray.to_gpu(a)
c_gpu = linalg.dot(a_gpu,a_gpu)
return c_gpu.get()
r=[]
Pool=mp.Pool(10)
for i in range(1000):
Pool.apply_async(my_proc,(random.randint(0,1),))
I keep getting
pycuda._driver.LogicError: cuCtxPopCurrent failed: invalid device context
Is there somthing I should be doing?