diff --git a/pennylane_lightning/core/src/bindings/BindingsCudaUtils.hpp b/pennylane_lightning/core/src/bindings/BindingsCudaUtils.hpp index 2a04ad4d63..c482e40511 100644 --- a/pennylane_lightning/core/src/bindings/BindingsCudaUtils.hpp +++ b/pennylane_lightning/core/src/bindings/BindingsCudaUtils.hpp @@ -65,7 +65,15 @@ void registerCudaUtils(py::module_ &m) { .def("syncDevice", &DevicePool::syncDevice) .def("refresh", &DevicePool::refresh) .def_static("getTotalDevices", &DevicePool::getTotalDevices) - .def_static("getDeviceUIDs", &DevicePool::getDeviceUIDs) + .def_static("getDeviceUIDs", [](){ + auto data = DevicePool::getDeviceUIDs(); + std::vector data_conv; + data_conv.reserve(data.size()); + for(auto d : data){ + data_conv.push_back(py::bytes(std::move(d))); + } + return data_conv; + }) .def_static("setDeviceID", &DevicePool::setDeviceIdx) .def(py::pickle( []([[maybe_unused]] const DevicePool &self) { // __getstate__ diff --git a/pennylane_lightning/core/src/utils/cuda_utils/DevicePool.hpp b/pennylane_lightning/core/src/utils/cuda_utils/DevicePool.hpp index 7ef3e25268..5bd1985680 100644 --- a/pennylane_lightning/core/src/utils/cuda_utils/DevicePool.hpp +++ b/pennylane_lightning/core/src/utils/cuda_utils/DevicePool.hpp @@ -127,15 +127,15 @@ template class DevicePool { * * @return std::vector */ - static std::vector getDeviceUIDs() { + static std::vector getDeviceUIDs() { int deviceCount; cudaGetDeviceCount(&deviceCount); int device; - std::vector dev_uid(deviceCount); + std::vector dev_uid(deviceCount); for (device = 0; device < deviceCount; device++) { cudaDeviceProp deviceProp; cudaGetDeviceProperties(&deviceProp, device); - dev_uid[device] = deviceProp.uuid; + dev_uid[device] = std::string(deviceProp.uuid.bytes); } return dev_uid; }