Skip to content

Instantly share code, notes, and snippets.

@hariby
hariby / pytket_braket_example.py
Created February 24, 2021 01:42
Amazon Braket integration example for pytket https://github.com/CQCL/pytket
pip install pytket pytket-braket
from pytket import Circuit
from pytket.backends.braket import BraketBackend
circ = Circuit(2)
circ.H(0)
circ.CX(0,1)
braket_backend = BraketBackend(local=False, s3_bucket='amazon-braket-XXXXXXXXXXXX', s3_folder='pytket/sample')
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hariby
hariby / reset_neptune_db.py
Created February 22, 2021 10:12
Neptune Workbench command from Notebook which delete the whole graph. https://aws.amazon.com/blogs/database/resetting-your-graph-data-in-amazon-neptune-in-seconds/
response = %db_reset --generate-token
token = response['payload']['token']
%db_reset --token $token
@hariby
hariby / braket-cost.sh
Created January 21, 2021 03:11
You can check cost of your recent Amazon Braket tasks (based on the pricing table as of 2021-01-21). Compatible with AWS CloudShell.
aws braket search-quantum-tasks --region us-west-2 --filters 'name=deviceArn,operator=EQUAL,values=arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6' | jq '.[] | map({quantumTaskArn: .quantumTaskArn, price: (.shots * 0.00019 + 0.30000)})'
aws braket search-quantum-tasks --region us-west-2 --filters 'name=deviceArn,operator=EQUAL,values=arn:aws:braket:::device/qpu/d-wave/Advantage_system1' | jq '.[] | map({quantumTaskArn: .quantumTaskArn, price: (.shots * 0.00019 + 0.30000)})'
aws braket search-quantum-tasks --region us-east-1 --filters 'name=deviceArn,operator=EQUAL,values=arn:aws:braket:::device/qpu/ionq/ionQdevice' | jq '.[] | map({quantumTaskArn: .quantumTaskArn, price: (.shots * 0.01000 + 0.30000)})'
aws braket search-quantum-tasks --region us-west-1 --filters 'name=deviceArn,operator=EQUAL,values=arn:aws:braket:::device/qpu/rigetti/Aspen-8' | jq '.[] | map({quantumTaskArn: .quantumTaskArn, price: (.shots * 0.00035 + 0.30000)})'
@hariby
hariby / README.md
Last active June 30, 2021 12:20
AWS DevDay 2020 Kubeflow Pipelines - SageMaker Workshop
@hariby
hariby / blueoil_infer_arm.sh
Last active June 6, 2020 07:19
Blueoil CIFAR-10 sample inference setup with EC2 A1/M6g (Graviton/Graviton2) instances
sudo easy_install pip
sudo yum groupinstall "Development Tools" -y
sudo yum install libjpeg-devel -y
cd cifar10_sample/export/save.ckpt-78125/32x32/output/python/
pip3 install -r requirements.txt
wget https://docs.blueoil.org/_static/airplane.png
python run.py -i airplane.png -m ../models/lib/libdlk_aarch64.so -c ../models/meta.yaml
@hariby
hariby / blueqat-qgate-on-start.sh
Last active November 7, 2019 05:08
Install Blueqat and Qgate to conda_python3 kernel when starting a SageMaker Notebook instance.
#!/bin/bash
set -e
# OVERVIEW
# This script installs a single pip package in a single SageMaker conda environments.
# Slightly modified from https://github.com/aws-samples/amazon-sagemaker-notebook-instance-lifecycle-config-samples/blob/master/scripts/install-pip-package-single-environment/on-start.sh
sudo -u ec2-user -i <<'EOF'
# PARAMETERS
#!/bin/bash
set -e
sudo -u ec2-user -i <<'EOF'
git clone https://github.com/awslabs/git-secrets.git
cd git-secrets/
sudo make install
git secrets --register-aws --global
@hariby
hariby / create_sagemaker_layer.sh
Last active July 13, 2019 09:18
Creating a SageMaker Python SDK Lambda Layer. Merge after AWSLambda-Python37-SciPy1x
#!/bin/bash
mkdir python
python3 -m pip install -r sagemaker-sdk-requirements.txt -t ./python/ --no-deps
zip sagemaker-sdk-layer.zip -r ./python/
rm -rf python
@hariby
hariby / predict_image.ipynb
Last active July 2, 2019 01:58
Simple example for pre-trained model (https://mxnet.incubator.apache.org/versions/master/tutorials/python/predict_image.html) deployment with Amazon SageMaker.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.