Refactor error handling in init_gpu