From 0b71367397668572b057ddda88026d8ddb7238ca Mon Sep 17 00:00:00 2001 From: Pablo Andres-Martinez <104848389+PabloAndresCQ@users.noreply.github.com> Date: Thu, 4 Apr 2024 09:55:16 +0100 Subject: [PATCH] Changing the order of commands so that GPU device is assigned before libhandle creation. (#92) --- pytket/extensions/cutensornet/structured_state/general.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pytket/extensions/cutensornet/structured_state/general.py b/pytket/extensions/cutensornet/structured_state/general.py index fc862dc2..0d07c10e 100644 --- a/pytket/extensions/cutensornet/structured_state/general.py +++ b/pytket/extensions/cutensornet/structured_state/general.py @@ -54,7 +54,6 @@ class CuTensorNetHandle: """ def __init__(self, device_id: Optional[int] = None): - self.handle = cutn.create() self._is_destroyed = False # Make sure CuPy uses the specified device @@ -63,6 +62,8 @@ def __init__(self, device_id: Optional[int] = None): dev = cp.cuda.Device() self.device_id = int(dev) + self.handle = cutn.create() + def __enter__(self) -> CuTensorNetHandle: return self