-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
508 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
### NVIDIA NIM Blueprints on GKE | ||
|
||
Here you will find the NVIDIA NIM Blueprints that can be provisioned to run on GKE. These are good for proof of concepts only. | ||
|
||
- [ ] [Generative Virtual Screening for Drug Discovery](./drugdiscovery/README.md) uses 3 NIMs | ||
- AlphaFold2 | ||
- MolMIM | ||
- DiffDock |
177 changes: 177 additions & 0 deletions
177
tutorials-and-examples/nvidia-nim/blueprints/drugdiscovery/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
# Generative Virtual Screening for Drug Discovery on GKE | ||
|
||
This guide outlines the steps to deploy NVIDIA's NIM blueprint for [Generative Virtual screening for Drug Discovery](https://build.nvidia.com/nvidia/generative-virtual-screening-for-drug-discovery) on a Google Kubernetes Engine (GKE) cluster. Three NIMs - AlphaFold2, MolMIM & DiffDock are used to demonstrate Protein folding, molecular generation and protein docking. | ||
|
||
## Prerequisites | ||
|
||
* **GCloud SDK:** Ensure you have the Google Cloud SDK installed and configured. | ||
* **Project:** A Google Cloud project with billing enabled. | ||
* **NGC API Key:** An API key from NVIDIA NGC. | ||
* **kubectl:** kubectl command-line tool installed and configured. | ||
|
||
Clone the repo before proceeding further: | ||
`git clone https://github.com/GoogleCloudPlatform/ai-on-gke` | ||
`cd ai-on-gke/tutorials-and-examples/nvidia-nim/blueprints/drugdiscovery` | ||
|
||
## Deployment Steps | ||
|
||
1. **Set Project and Variables:** | ||
|
||
```bash | ||
|
||
gcloud config set project "<GCP Project ID>" | ||
export PROJECT_ID=$(gcloud config get project) | ||
export CLUSTER_NAME="gke-nimbp-genscr" | ||
export NODE_POOL_NAME="gke-nimbp-genscr-np" | ||
export ZONE="<GCP zone>" #us-east5-b | ||
export MACHINE_TYPE= "<GCP machine type>" #"a2-ultragpu-1g" | ||
export ACCELERATOR_TYPE="<GPU Type>" #"nvidia-a100-80gb" | ||
export ACCELERATOR_COUNT="1" | ||
export NODE_POOL_NODES=3 | ||
export NGC_API_KEY="<NGC API Key>" | ||
|
||
``` | ||
|
||
2. **Create GKE Cluster:** This creates the initial cluster with a default node pool for management tasks. GPU nodes will be added in the next step. | ||
|
||
```bash | ||
gcloud container clusters create "${CLUSTER_NAME}" \ | ||
--project="${PROJECT_ID}" \ | ||
--num-nodes=1 --location="${ZONE}" \ | ||
--machine-type=e2-standard-16 \ | ||
--addons=GcpFilestoreCsiDriver | ||
``` | ||
|
||
3. **Create GPU Node Pool:** This creates a node pool with GPU machines optimized for BioNeMo workloads. | ||
|
||
```bash | ||
gcloud container node-pools create "${NODE_POOL_NAME}" \ | ||
--cluster="${CLUSTER_NAME}" \ | ||
--location="${ZONE}" \ | ||
--node-locations="${ZONE}" \ | ||
--num-nodes="${NODE_POOL_NODES}" \ | ||
--machine-type="${MACHINE_TYPE}" \ | ||
--accelerator="type=${ACCELERATOR_TYPE},count=${ACCELERATOR_COUNT},gpu-driver-version=LATEST" \ | ||
--placement-type="COMPACT" \ | ||
--disk-type="pd-ssd" \ | ||
--disk-size="500GB" | ||
``` | ||
|
||
4. **Get Cluster Credentials:** | ||
|
||
```bash | ||
gcloud container clusters get-credentials "${CLUSTER_NAME}" --location="${ZONE}" | ||
``` | ||
|
||
5. **Set kubectl Alias (Optional):** | ||
|
||
```bash | ||
alias k=kubectl | ||
``` | ||
|
||
6. **Create NGC Secret:** Creates the secret for pulling images from NVIDIA NGC. **Important:** Replace the placeholder API key with your actual NGC API Key. | ||
|
||
```bash | ||
k create secret docker-registry secret-nvcr \ | ||
--docker-username=\$oauthtoken \ | ||
--docker-password="${NGC_API_KEY}" \ | ||
--docker-server="nvcr.io" | ||
``` | ||
|
||
7. **Deploy BioNeMo Services:** Deploy AlphaFold2, MolMIM, and DiffDock. | ||
|
||
```bash | ||
k create -f nim-storage-filestore.yaml | ||
k create -f nim-bionemo-generative-virtual-screening.yaml | ||
``` | ||
|
||
8. **Port Forwarding (for local testing):** These commands forward the service ports to your local machine for testing. Replace the pod names with the actual names of your deployed pods. | ||
|
||
```bash | ||
POD_BIONEMO_ALPHAFOLD=$(k get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | grep '^alphafold2') | ||
k port-forward pod/$POD_BIONEMO_ALPHAFOLD :8000 | ||
POD_BIONEMO_MOLMIM=$(k get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | grep '^molmim') | ||
k port-forward pod/$POD_BIONEMO_MOLMIM :8000 | ||
POD_BIONEMO_DIFFDOCK=$(k get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | grep '^diffdock') | ||
k port-forward pod/$POD_BIONEMO_DIFFDOCK :8000 | ||
``` | ||
|
||
9. **Test Deployments:** Use `curl` or other tools to test the deployed services by sending requests to the forwarded ports. Examples are provided in the `dev.sh` file. | ||
|
||
```bash | ||
# AlphaFold2 | ||
curl \ | ||
--max-time 900 \ | ||
-X POST \ | ||
-i \ | ||
"http://localhost:62921/protein-structure/alphafold2/predict-structure-from-sequence" \ | ||
-H 'accept: application/json' \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{ | ||
"sequence": "MVPSAGQLALFALGIVLAACQALENSTSPLSADPPVAAAVVSHFNDCPDSHTQFCFHGTCRFLVQEDKPACVCHSGYVGARCEHADLLAVVAASQKKQAITALVVVSIVALAVLIITCVLIHCCQVRKHCEWCRALICRHEKPSALLKGRTACCHSETVV", | ||
"databases": [ | ||
"small_bfd" | ||
] | ||
}' | ||
``` | ||
|
||
```bash | ||
# MolMIM | ||
curl -X POST \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{ | ||
"smi": "CC1(C2C1C(N(C2)C(=O)C(C(C)(C)C)NC(=O)C(F)(F)F)C(=O)NC(CC3CCNC3=O)C#N)C", | ||
"num_molecules": 5, | ||
"algorithm": "CMA-ES", | ||
"property_name": "QED", | ||
"min_similarity": 0.7, | ||
"iterations": 10 | ||
}' \ | ||
"http://localhost:49530/generate" | ||
``` | ||
|
||
10. **Test end to end:** | ||
Update the AF2_HOST, MOLMIM_HOST and DIFFDOCK_HOST variables with port numbers in `test-generative-virtual-screening.py` file. | ||
|
||
```bash | ||
python3 -m venv venv | ||
source venv/bin/activate | ||
pip3 install requests | ||
python3 test-generative-virtual-screening.py | ||
deactivate | ||
``` | ||
|
||
## Cleanup | ||
|
||
To delete the cluster and all associated resources: | ||
|
||
```bash | ||
k delete secret secret-nvcr | ||
k delete -f nim-bionemo-generative-virtual-screening.yaml | ||
k delete -f nim-storage-filestore.yaml | ||
gcloud container clusters delete "${CLUSTER_NAME}" --location="${ZONE}" | ||
``` |
189 changes: 189 additions & 0 deletions
189
...xamples/nvidia-nim/blueprints/drugdiscovery/nim-bionemo-generative-virtual-screening.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: alphafold2 | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: alphafold2 | ||
template: | ||
metadata: | ||
labels: | ||
app: alphafold2 | ||
spec: | ||
containers: | ||
- name: alphafold2 | ||
image: nvcr.io/nim/deepmind/alphafold2:2.1.0 | ||
securityContext: | ||
runAsUser: 0 | ||
ports: | ||
- containerPort: 8000 | ||
volumeMounts: | ||
- name: alphafold2-cache | ||
mountPath: /data | ||
env: | ||
- name: NGC_API_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: ngc-api-key # Replace with your actual secret name | ||
key: NGC_API_KEY | ||
- name: NIM_CACHE_PATH | ||
value: /data | ||
- name: NIM_MODEL_ORG | ||
value: nim | ||
- name: NIM_MODEL_TEAM | ||
value: deepmind | ||
resources: | ||
requests: | ||
nvidia.com/gpu: 1 | ||
limits: | ||
nvidia.com/gpu: 1 | ||
volumes: | ||
- name: alphafold2-cache | ||
persistentVolumeClaim: | ||
claimName: nim-storage-filestore | ||
imagePullSecrets: | ||
- name: secret-nvcr | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: molmim | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: molmim | ||
template: | ||
metadata: | ||
labels: | ||
app: molmim | ||
spec: | ||
containers: | ||
- name: molmim | ||
image: nvcr.io/nim/nvidia/molmim:1.0.0 | ||
securityContext: | ||
runAsUser: 0 | ||
ports: | ||
- containerPort: 8000 | ||
volumeMounts: | ||
- name: molmim-cache | ||
mountPath: /data | ||
env: | ||
- name: NGC_API_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: ngc-api-key # Replace with your actual secret name | ||
key: NGC_API_KEY | ||
- name: NIM_CACHE_PATH | ||
value: /data | ||
resources: | ||
requests: | ||
nvidia.com/gpu: 1 | ||
limits: | ||
nvidia.com/gpu: 1 | ||
volumes: | ||
- name: molmim-cache | ||
persistentVolumeClaim: | ||
claimName: nim-storage-filestore | ||
imagePullSecrets: | ||
- name: secret-nvcr | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: diffdock | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: diffdock | ||
template: | ||
metadata: | ||
labels: | ||
app: diffdock | ||
spec: | ||
containers: | ||
- name: diffdock | ||
image: nvcr.io/nim/mit/diffdock:2.0 | ||
securityContext: | ||
runAsUser: 0 | ||
ports: | ||
- containerPort: 8000 | ||
volumeMounts: | ||
- name: diffdock-cache | ||
mountPath: /data | ||
env: | ||
- name: NGC_API_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: ngc-api-key # Replace with your actual secret name | ||
key: NGC_API_KEY | ||
- name: NVIDIA_VISIBLE_DEVICES | ||
value: "0" # Set the default value here | ||
- name: NIM_CACHE_PATH | ||
value: /data | ||
resources: | ||
requests: | ||
nvidia.com/gpu: 1 | ||
limits: | ||
nvidia.com/gpu: 1 | ||
imagePullSecrets: | ||
- name: secret-nvcr | ||
volumes: | ||
- name: diffdock-cache | ||
persistentVolumeClaim: | ||
claimName: nim-storage-filestore | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: alphafold2-service | ||
spec: | ||
selector: | ||
app: alphafold2 | ||
ports: | ||
- protocol: TCP | ||
port: 8081 | ||
targetPort: 8000 | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: diffdock-service | ||
spec: | ||
selector: | ||
app: diffdock | ||
ports: | ||
- protocol: TCP | ||
port: 8082 | ||
targetPort: 8000 | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: molmim-service | ||
spec: | ||
selector: | ||
app: molmim | ||
ports: | ||
- protocol: TCP | ||
port: 8083 | ||
targetPort: 8000 | ||
|
||
--- | ||
# Create a Secret to hold the NGC API key | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: ngc-api-key | ||
type: Opaque | ||
stringData: | ||
NGC_API_KEY: <NGC API Key> |
Oops, something went wrong.