I am using PyTorch multiprocessing queues in order to exchange data between the subprocesses and the father process. These subprocesses are used to sample data from a simulation environment which then will be used in order to train a network. After many iterations of sampling which execute correctly, I get a segmentation fault accessing the queue without traceback. I really don’t know what is happening: Here is the part related to the queues and the subprocess:
        batch = []

        for i in range(6):
            batch_range = (batch_size // 6 * i, batch_size // 6 * (i + 1))
            batch += drain(env, gamma, policy, horizon, render, speedup, seed, batch_range, in_queue, out_queue)

def drain(env, gamma, policy, horizon, render, speedup, seed, batch_range, in_queue, out_queue):

    for i in range(batch_range[0], batch_range[1]):
        in_queue.put((env, gamma, policy, horizon, render, speedup, seed * 1000 + i))

    batch = []
    for i in range(batch_range[0], batch_range[1]):
        batch.append(out_queue.get())

    return batch

I tried to split the processed data in chunks because I thought the amount of data exchanged over the out queue could be an issue.
Some details:

The queues are torch.multiprocessing.Queue
The policy is a class containing a PyTorch network used to act on the simulation environment