-
I want to run a circuit simulation ( What I have so far:Following the docs https://nvidia.github.io/cuda-quantum/0.9.0/using/examples/multi_gpu_workflows.html#circuit-batching I managed to use the asynchronous Questions:
MWEimport cudaq
cudaq.set_target("nvidia", option="mqpu,fp64")
print('number of gpus found:', cudaq.num_available_gpus())
@cudaq.kernel
def kernel():
q = cudaq.qvector(2)
h(q)
shots_count = int(1e6)
# The following line fails with the error: "TypeError: sample() got an unexpected keyword argument 'qpu_id'"
#print(cudaq.sample(kernel, shots_count=shots_count, qpu_id=3))
# The following line works, but always runs on GPU 0
print(cudaq.sample(kernel, shots_count=shots_count))
# The following line works, and respects the qpu_id argument, but is asynchronous.
samples_async = cudaq.sample_async(kernel, shots_count=shots_count, qpu_id=3)
print(samples_async.get()) Prints:
Edit:Environment
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi Oliver, thanks for your question! I do believe that If you want to target a specific GPU more generally, I'd recommend setting the |
Beta Was this translation helpful? Give feedback.
-
Hi Mitchell, thanks for the clarification. |
Beta Was this translation helpful? Give feedback.
Hi Oliver, thanks for your question!
I do believe that
cudaq.sample_async
is the only function able to target a specific GPU, but I might be wrong off the top of my head.If you want to target a specific GPU more generally, I'd recommend setting the
CUDA_VISIBLE_DEVICES
environment variable to a comma separated list of the GPU device IDs you would like to expose.