Install the Amazon Braket SDK and run quantum circuits in Jupyter Notebook."
This article explains how to install the Amazon Braket SDK, a quantum computing SDK provided by AWS, and run it on Jupyter Notebook.
Amazon Braket Learning Course
For those who want to learn more about Amazon Braket mentioned in this article, here is an introduction to the Amazon Braket learning course.
This course is designed for those with no prior knowledge of quantum computing or AWS, and by the end, you’ll even be able to learn about quantum machine learning. Take advantage of this opportunity to build your skills in quantum technologies!
Install the Amazon Braket SDK and run quantum circuits in Jupyter Notebook.
The Amazon Braket SDK is a quantum computing software development kit provided by AWS, and it can be used with Python. This SDK allows you to define and execute quantum circuits.
While the Amazon Braket SDK can be easily used through Amazon Braket Notebooks-Jupyter Notebook instances running on AWS-in this guide, we will explain how to install and run the SDK directly on your local PC or server.
The environment is Windows 10, and I’m using Python 3.9.9.
First, here is an example where the installation didn’t go as expected.
I tried installing the Amazon Braket SDK using the following command:
pip install amazon-braket-sdk[braket-air,notebook]
After launching the environment with the jupyter notebook
command, try running the following code.
from braket.circuits import Circuit
from braket.devices import LocalSimulator
circuit = Circuit().h(0).measure(0)
device = LocalSimulator()
result = device.run(circuit, shots=1000).result()
counts = result.measurement_counts
print(counts)
The result fails with the following error message.
ModuleNotFoundError: No module named 'braket'
Next, we’ll show a successful example. The environment will be prepared as follows.
pip install amazon-braket-sdk notebook
After launching the environment with the jupyter notebook
command, try running the same code. This time, the output appears as shown below, confirming that the quantum circuit was successfully executed.
Counter({'0': 515, '1': 485})
Amazon Braket Learning Course
For those who want to learn more about Amazon Braket mentioned in this article, here is an introduction to the Amazon Braket learning course.
This course is designed for those with no prior knowledge of quantum computing or AWS, and by the end, you’ll even be able to learn about quantum machine learning. Take advantage of this opportunity to build your skills in quantum technologies!