2

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([])

1 Answers1

2

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.

ryanhill1
  • 2,668
  • 1
  • 11
  • 39