@ptrblck I tried again to debug the code. The problem is there every time I use a collate_fn that is a method of a class that contains the model as one of its attributes (self.model). Each time this happens, there is a new cuda context created. I don’t know if this can be considered a bug or it is a normal behavior known by the developers