Skip to content

Commit 067a14a

Browse files
committed
Additional tutorial details added.
1 parent 6f76338 commit 067a14a

File tree

2 files changed

+101
-51
lines changed

2 files changed

+101
-51
lines changed
11.5 KB
Loading

nvidia-nemo-oke/readme.md

Lines changed: 101 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@
7474
13. The command you just executed will create your Kube config file. To test it, run the following:
7575

7676
```bash
77-
<copy>
7877
kubectl cluster-info
7978
kubectl get nodes -o wide
80-
</copy>
8179
```
8280

8381
>Note: The GPU nodes may still be provisioning and might not show up just yet. The node name is its private IP address.
@@ -96,7 +94,6 @@
9694
1. Return to Cloud Shell. Create a new file called **jh-values.yaml** and paste the following:
9795

9896
```
99-
<copy>
10097
# default configuration
10198
singleuser:
10299
cloudMetadata:
@@ -108,33 +105,26 @@
108105
# kubespawner_override:
109106
# extra_resource_limits:
110107
# nvidia.com/gpu: "1"
111-
</copy>
112108
```
113109

114110
>Note: In this tutorial we use Jupyter notebooks to interact with the GPU-driven NVIDIA microservices. You will not need to enable GPU-based user notebooks to complete the tasks herein.
115111

116112
2. Add the Helm repo.
117113

118114
```bash
119-
<copy>
120115
helm repo add jupyterhub https://hub.jupyter.org/helm-chart/ && helm repo update
121-
</copy>
122116
```
123117

124118
3. Perform the install using Helm, and reference the values file created in step 1.
125119

126120
```bash
127-
<copy>
128121
helm upgrade --cleanup-on-fail –install jupyter-hub jupyterhub/jupyterhub --namespace k8s-jupyter --create-namespace --values jh-values.yaml
129-
</copy>
130122
```
131123

132124
4. Once the deployment is complete, the Kubernetes service that gets created will provision an OCI Load Balancer for public access. Locate the public IP address of the load balancer and store it for later.
133125

134126
```bash
135-
<copy>
136127
kubectl get svc -n k8s-jupyter
137-
</copy>
138128
```
139129

140130
Output:
@@ -150,7 +140,6 @@
150140
1. Before creating the database, you'll need to create role-based access control (RBAC) for the node. Create a file called **node-rbac.yaml** and paste the following:
151141

152142
```
153-
<copy>
154143
---
155144
apiVersion: rbac.authorization.k8s.io/v1
156145
kind: ClusterRole
@@ -178,13 +167,11 @@
178167
name: default
179168
namespace: oracle-database-operator-system
180169
---
181-
</copy>
182170
```
183171

184172
2. Create a file called **db-admin-secret.yaml** that will be used to set the DB password upon deployment. Paste the follwing:
185173

186174
```
187-
<copy>
188175
apiVersion: v1
189176
kind: Secret
190177
metadata:
@@ -193,15 +180,13 @@
193180
type: Opaque
194181
stringData:
195182
oracle_pwd: YOURPASSWORDHERE
196-
</copy>
197183
```
198184

199185
>Note: Be sure to replace the **YOURPASSWORDHERE** above with a value of your own choosing. At least 15 characters, 2 upper case, 2 lower case, 2 numbers, and 2 special characters.
200186

201187
3. Create a file called **db23ai-instance.yaml** and paste the following:
202188

203189
```
204-
<copy>
205190
apiVersion: database.oracle.com/v1alpha1
206191
kind: SingleInstanceDatabase
207192
metadata:
@@ -224,23 +209,18 @@
224209

225210
replicas: 1
226211
---
227-
</copy>
228212
```
229213

230214
4. Apply the manifests using the following command; this creates the RBAC, the password, and the DB pod.
231215

232216
```bash
233-
<copy>
234217
kubectl apply -n oracle23ai -f node-rbac.yaml,db-admin-secret.yaml,db23ai-instance.yaml
235-
</copy>
236218
```
237219

238220
5. After the command completes, it may take 3-5 minutes for the DB instance to come online. You can check the status with the following command. Do not proceed until the status is **Healthy**
239221

240222
```bash
241-
<copy>
242223
kubectl get singleinstancedatabase -n oracle23ai
243-
</copy>
244224
```
245225

246226
Output:
@@ -250,25 +230,23 @@
250230
nemo-23ai Free Healthy PRIMARY 23.4.0.24.05 10.0.10.246:31452/FREE Unavailable Unavailable
251231
```
252232

233+
>Note: Be sure to write down the connection string for later. You'll need the IP address and port number.
234+
253235
6. Run the following command to gather details about the DB instance and set them to environment variables.
254236
255237
```bash
256-
<copy>
257238
export ORA_PASS=$(kubectl get secret/freedb-admin-secret -n oracle23ai -o jsonpath='{.data.oracle_pwd}' | base64 -d)
258239
export ORACLE_SID=$(kubectl get singleinstancedatabase -n oracle23ai -o 'jsonpath={.items[0].metadata.name}')
259240
export ORA_POD=$(kubectl get pods -n oracle23ai -o jsonpath='{.items[0].metadata.name}')
260241
export ORA_CONN=$(kubectl get singleinstancedatabase ${ORACLE_SID} -n oracle23ai -o "jsonpath={.status.connectString}")
261-
</copy>
262242
```
263243
264244
>Note: If you leave Cloud Shell and return later, you'll need to run the above commands again if you wish to connect to the DB instance directly. That said, after this section, all DB access should be done via Jupyter Notebooks.
265245

266246
7. Connect to the DB instance.
267247

268248
```bash
269-
<copy>
270249
kubectl exec -it pods/${ORA_POD} -n oracle23ai -- sqlplus sys/${ORA_PASS}@${ORACLE_SID} as sysdba
271-
</copy>
272250
```
273251

274252
8. Create a vector DB user that will enable your Python code to access the vector data store.
@@ -283,35 +261,61 @@
283261
9. Type *exit* to leave the container.
284262
285263
## Task 4: Prepare the NeMo deployment
286-
**TODO:** Clean up this section.
287264
288-
23. Now to prep for the NeMo deployment. Create a new Kubernetes namespace.
265+
1. Now to prep for the NeMo deployment. Create a new Kubernetes namespace.
289266
290-
kubectl create ns embedding-nim
267+
```bash
268+
kubectl create ns embedding-nim
269+
```
291270
292-
24. Add your NGC API Key to an environment variable.
271+
2. Add your NGC API Key to an environment variable.
272+
273+
```
274+
export NGC_API_KEY=<your api key here>
275+
```
293276
294-
export NGC_API_KEY=<your api key here>
277+
>Note: Paste your own API key in place of `<your api key here>`; remove the <> brackets and encapsulate within double quotes "".
295278
296-
25. Confirm that your key gets you access to the NVCR container registry:
279+
3. Confirm that your key gets you access to the NVCR container registry:
297280
298-
echo "$NGC_API_KEY" | docker login nvcr.io --username '$oauthtoken' --password-stdin
281+
```
282+
echo "$NGC_API_KEY" | docker login nvcr.io --username '$oauthtoken' --password-stdin
283+
```
299284
300-
You should get Login Succeeded
285+
You should get Login Succeeded:
301286
302-
26. Create a docker-registry secret in Kubernetes. The kubelet will use this secret to download the container images needed to run pods.
287+
```bash
288+
echo "$NGC_API_KEY" | docker login nvcr.io --username '$oauthtoken' --password-stdin
289+
WARNING! Your password will be stored unencrypted in /home/username/.docker/config.json.
290+
Configure a credential helper to remove this warning. See
291+
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
303292
304-
kubectl -n embedding-nim create secret docker-registry registry-secret --docker-server=nvcr.io --docker-username='$oauthtoken' --docker-password=$NGC_API_KEY
293+
Login Succeeded
294+
```
295+
296+
>Note: If you do not see the Login Succeeded message, you'll need to troubleshoot your API key on the NVIDIA website.
297+
298+
4. Create a docker-registry secret in Kubernetes. The kubelet will use this secret to download the container images needed to run pods.
299+
300+
```
301+
kubectl -n embedding-nim create secret docker-registry registry-secret --docker-server=nvcr.io --docker-username='$oauthtoken' --docker-password=$NGC_API_KEY
302+
```
303+
304+
5. Create a secret for your NGC API KEY that will be passed to your pod via environment variable later.
305+
306+
```
307+
kubectl -n embedding-nim create secret generic ngc-api-key --from-literal=ngc-api-key=”$NGC_API_KEY
308+
```
305309

306-
27. Create a secret for your NGC API KEY that will be passed to your pod via environment variable later.
310+
6. You can check the value with the following command.
307311

308-
kubectl -n embedding-nim create secret generic ngc-api-key --from-literal=ngc-api-key=”$NGC_API_KEY
309-
28. You can check the value with the following command.
312+
```
313+
kubectl -n embedding-nim get secret/ngc-api-key -o jsonpath='{.data.ngc-api-key}' | base64 -d
314+
```
310315

311-
kubectl -n embedding-nim get secret/ngc-api-key -o jsonpath='{.data.ngc-api-key}' | base64 -d
316+
7. Next, you’ll create three separate files to deploy the NeMo retriever microservices.
312317

313-
29. Next, you’ll create three separate files to deploy the NeMo retriever microservices.
314-
a. llama3-8b-instruct.yaml
318+
a. **llama3-8b-instruct.yaml**
315319

316320
```
317321
<copy>
@@ -346,7 +350,7 @@ kubectl -n embedding-nim get secret/ngc-api-key -o jsonpath='{.data.ngc-api-key}
346350
</copy>
347351
```
348352

349-
b. nv-embedqa-e5-v5.yaml
353+
b. **nv-embedqa-e5-v5.yaml**
350354

351355
```
352356
<copy>
@@ -381,7 +385,7 @@ kubectl -n embedding-nim get secret/ngc-api-key -o jsonpath='{.data.ngc-api-key}
381385
</copy>
382386
```
383387

384-
c. nv-rerankqa-mistral-4b-v3.yaml
388+
c. **nv-rerankqa-mistral-4b-v3.yaml**
385389

386390
```
387391
<copy>
@@ -416,20 +420,16 @@ kubectl -n embedding-nim get secret/ngc-api-key -o jsonpath='{.data.ngc-api-key}
416420
</copy>
417421
```
418422

419-
30. Apply the 3 manifest files to your Kubernetes cluster.
423+
8. Apply the 3 manifest files to your Kubernetes cluster.
420424

421425
```bash
422-
<copy>
423426
kubectl -n embedding-nim apply -f llama3-8b-instruct.yaml,nv-embedqa-e5-v5.yaml,nv-rerankqa-mistral-4b-v3.yaml
424-
</copy>
425427
```
426428

427-
31. View the pods to ensure they are all running.
429+
9. View the pods to ensure they are all running.
428430

429431
```bash
430-
<copy>
431432
kubectl -n embedding-nim get pods -o wide
432-
</copy>
433433
```
434434

435435
Output:
@@ -442,12 +442,62 @@ kubectl -n embedding-nim get secret/ngc-api-key -o jsonpath='{.data.ngc-api-key}
442442
```
443443

444444

445-
32. Now that everything is up and running, you can return to your Jupyter-hub web page and launch a new notebook.
445+
10. Now that everything is up and running, you can return to your JupyterHub web page and launch a new notebook. If you need to double-check the IP address of your JupyterHub instance, run the following command:
446+
447+
```
448+
kubectl get svc -n k8s-jupyter
449+
```
450+
451+
>Note: make sure to access via HTTP and not HTTPS as we did not configure TLS in this exercise.
452+
453+
11. Within the notebook, install the oracledb libraries:
446454

447-
33. Within the notebood, install the oracledb libraries
455+
```
456+
pip install oracledb
457+
```
458+
459+
![Install Oracledb binaries](images/jupyter-install-oracledb.png)
460+
461+
12. Test connectivity to the Oracle Database. Add a second entry into the notebook and paste the following:
462+
463+
```
464+
import oracledb
465+
#from dotenv import load_dotenv
466+
import os
467+
# Load environment variables
468+
#load_dotenv()
469+
username = "c##vector"
470+
password = "<your password here>"
471+
host="<your db pod IP here>"
472+
port="<your db port here>"
473+
service_name="FREE"
474+
dsn=host+":"+port+"/"+service_name
475+
#dsn = "10.0.0.124:1521/DB0601_nvz_fra.subnet04021055.vcn04021055.oraclevcn.com"
476+
#COMPARTMENT_OCID = "ocid1.compartment.oc1..aaaaaaaamveskuaejui5qx3ohucymgnbnfidzh5kqw4ued5uv5rhi3mif4ta"
477+
print("The database user name is:", username)
478+
print("Database connection information is:", dsn)
479+
# Connect to the database
480+
try:
481+
conn23c = oracledb.connect(user=username, password=password, dsn=dsn)
482+
print("Connection successful!")
483+
except oracledb.DatabaseError as e:
484+
error, = e.args
485+
print(f"Connection failed. Error code: {error.code}")
486+
print(f"Error message: {error.message}")
487+
```
488+
489+
>Note: Be sure to enter the password you created, along with the pod IP and port number from task 3 step 5.
490+
491+
13. Run the notebook task:
492+
493+
```
494+
The database user name is: c##vector
495+
Database connection information is: 10.0.10.246:31452/FREE
496+
Connection successful!
448497
449-
pip install oracledb
498+
## Task 5: Working with sample reranking and embedding notebooks
450499
500+
1.
451501
452502
453503

0 commit comments

Comments
 (0)