CUDA ERROR: initialization error when using parallel in python
Question: I use CUDA for my code, but it still slow run. Therefore I change it to run
parallel using multiprocessing (pool.map) in python. But I have `CUDA ERROR:
initialization error`

This Is function :

    
    
    def step_M(self, iter_training):
        gpe, e_tuple_list = iter_training
        g = gpe[0]
        p = gpe[1]
        em_iters = gpe[2]
    
        e_tuple_list = sorted(e_tuple_list, key=lambda tup: tup[0])
        data = self.X[e_tuple_list[0][0]:e_tuple_list[0][1]]
        cluster_indices = np.array(range(e_tuple_list[0][0], e_tuple_list[0][1], 1), dtype=np.int32)
        for i in range(1, len(e_tuple_list)):
            d = e_tuple_list[i]
            cluster_indices = np.concatenate((cluster_indices, np.array(range(d[0], d[1], 1), dtype=np.int32)))
            data = np.concatenate((data, self.X[d[0]:d[1]]))
    
        g.train_on_subset(self.X, cluster_indices, max_em_iters=em_iters)
        return g, cluster_indices, data
    

And here code call:

    
    
    pool = Pool()
    iter_bic_list = pool.map(self.step_M, iter_training.items())
    

The iter_training same: [![enter image description
here](http://i.stack.imgur.com/Tv5rE.png)](http://i.stack.imgur.com/Tv5rE.png)

And this is errors [![enter image description
here](http://i.stack.imgur.com/fi6LM.png)](http://i.stack.imgur.com/fi6LM.png)
could you help me to fix.Thanks you.


Answer: I realize this is a bit old but I ran into the same problem, while running
under celery in my case:

    
    
    syncedmem.cpp:63] Check failed: error == cudaSuccess (3 vs. 0)  initialization error
    

Switching from prefork to an eventlet based pool has resolved the issue. Your
code could be updated similarly to:

    
    
    from eventlet import GreenPool
    pool = GreenPool()
    iter_bic_list = list(pool.imap(self.step_M, iter_training.items()))
    

