Fix for sharing cuda context in multiple threads