2
$\begingroup$

I have an error when I want to run the 'LocalSimulator'. I am not inside AWS, its mean I runnig from Google Colab. The code is the same on the notebooks from 0_Getting_started

    # general imports
    import matplotlib.pyplot as plt
    %matplotlib inline

    # AWS imports: Import Braket SDK modules
    from braket.circuits import Circuit
    from braket.devices import LocalSimulator

    # build a Bell state with two qubits. Here 'cnot(control=0, target=1)' can be 
     simplified as 'cnot(0,1)'
    bell = Circuit().h(0).cnot(control=0, target=1)
    # set up device
    device = LocalSimulator()

    # run circuit
     result = device.run(bell, shots=1000).result()
    # get measurement shots
    counts = result.measurement_counts
    # print counts
    print(counts)

And the result is

ValueError: Only the following devices are available dict_keys([])

$\endgroup$
3
  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Dec 22, 2023 at 7:05
  • $\begingroup$ Hi Sandra, we have not been able to reproduce the issue on our side. Could you tell us if @ryanhill1's solution fixed the problem? Otherwise, do you mind providing more guidance on how to reproduce it? Thanks $\endgroup$ Dec 29, 2023 at 16:50
  • $\begingroup$ oh! thanks. Yes the answer by @ryanhill1's worked. $\endgroup$ Jan 8 at 19:04

1 Answer 1

2
$\begingroup$

From the top-bar, click Runtime > Restart session, and then try again.

The error is coming from the _simulator_devices entry points dict returning empty when called on.

When you installed the amazon-braket-sdk in your Google Colab notebook, it registered its entry points in the environment. However, since Python's module system and the pkg_resources module in particular rely on internal caches for performance reasons, these new entry points weren't immediately visible to the already-running kernel. Restarting the kernel/session should fix the issue.

$\endgroup$
2
  • $\begingroup$ Thanks for your help. I wasn't sure if AWS worked externally to their website. But it's currently working, so thank you very much. It was something simple. $\endgroup$ Jan 8 at 19:06
  • 1
    $\begingroup$ @SandraRosales No problem! If my answer helped resolve could you mark it as accepted? Thanks! $\endgroup$
    – ryanhill1
    Jan 9 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.