Skip to content

Commit a85445a

Browse files
NIM online configuration fixes (#619)
* Readme updates for diffusion model * Add NIM vanilla container solution * Correct NIM online configurations * multi llm nim sample * multi llm NIM
1 parent a1a5a9f commit a85445a

File tree

2 files changed

+103
-2
lines changed

2 files changed

+103
-2
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Overview
2+
3+
This Readme walks through how to use NIM - [ Meta-Llama-3-8B-Instruct](https://huggingface.co/Undi95/Meta-Llama-3-8B-Instruct-hf) based container to deploy on OCI Data Science Model Deploy. This readme implements Multi llm NIM containers, in which you do not need to bring model specific images and a single image can host all supported LLMs.
4+
Read more about Multi-LLM NIMs - [here](https://docs.nvidia.com/nim/large-language-models/latest/introduction.html)
5+
6+
* [llama3](https://github.com/meta-llama/llama3) from Meta.
7+
* [NIM](https://catalog.ngc.nvidia.com/orgs/nim/teams/meta/containers/llama3-8b-instruct) by Nvidia
8+
9+
We describe two approaches to create this Model Deployment on OCI:
10+
* Download Model using API-KEY from NGC Nvidia (described below)
11+
* Utilising Object storage to store the model and creating a model catalog pointing to Object storage bucket [Refer](https://github.com/oracle-samples/oci-data-science-ai-samples/tree/main/model-deployment/containers/nim/README-MODEL-CATALOG.md)
12+
13+
## Prerequisites
14+
* Access the corresponding NIM container llm. Click Get Container Button and click Request Access for NIM. At the time of writing this blog, you need a business email address to get access to NIM.
15+
* For downloading this image from NGC catalog, you need to perform docker login to nvcr.io. Details of login information are mentioned on their [public doc](https://docs.nvidia.com/launchpad/ai/base-command-coe/latest/bc-coe-docker-basics-step-02.html).
16+
Once logged in, we can directly pull image using -
17+
`docker pull nvcr.io/nim/nvidia/llm-nim:1.12.0`
18+
* Generate API key to interact with NIM NGC APIs. [Reference document](https://org.ngc.nvidia.com/setup/api-key).
19+
* Once the image is successfully pulled on your workstation, we will bring this image to Oracle Cloud Infrastructure Registry (OCIR). The necessary policies and process for OCIR interaction are mentioned in our [public docs](https://docs.oracle.com/en-us/iaas/data-science/using/mod-dep-byoc.htm).
20+
21+
## OCI Logging
22+
When experimenting with new frameworks and models, it is highly advisable to attach log groups to model deployment in order to enable self assistance in debugging. Follow below steps to create log groups.
23+
24+
* Create logging for the model deployment (if you have to already created, you can skip this step)
25+
* Go to the [OCI Logging Service](https://cloud.oracle.com/logging/log-groups) and select `Log Groups`
26+
* Either select one of the existing Log Groups or create a new one
27+
* In the log group create ***two*** `Log`, one predict log and one access log, like:
28+
* Click on the `Create custom log`
29+
* Specify a name (predict|access) and select the log group you want to use
30+
* Under `Create agent configuration` select `Add configuration later`
31+
* Then click `Create agent configuration`
32+
33+
34+
##### To directly get image from Nvidia NIM catalogue and upload to OCIR check: ```./README-SOURCE-NIM-TO-OCIR.MD```
35+
36+
## OCI Container Registry
37+
38+
* You need to `docker login` to the Oracle Cloud Container Registry (OCIR) first, if you haven't done so before been able to push the image. To login, you have to use your [API Auth Token](https://docs.oracle.com/en-us/iaas/Content/Registry/Tasks/registrygettingauthtoken.htm) that can be created under your `Oracle Cloud Account->Auth Token`. You need to login only once.
39+
40+
```bash
41+
docker login -u '<tenant-namespace>/<username>' <region>.ocir.io
42+
```
43+
44+
If `your tenancy` is **federated** with Oracle Identity Cloud Service, use the format `<tenancy-namespace>/oracleidentitycloudservice/<username>`
45+
46+
* Push the container image to the OCIR
47+
48+
```bash
49+
docker push <region>.ocir.io/<tenant-namespace>/`llm-nim:1.12.0`
50+
```
51+
52+
## Deploy on OCI Data Science Model Deployment
53+
54+
Once you built and pushed the NIM container, you can now use the `Bring Your Own Container` Deployment in OCI Data Science to deploy the Llama3 model
55+
56+
### Creating Model catalog
57+
58+
Follow the steps mentioned [here](https://github.com/oracle-samples/oci-data-science-ai-samples/blob/main/model-deployment/containers/llama2/README.md#model-store-export-api-for-creating-model-artifacts-greater-than-6-gb-in-size)), refer the section One time download to OCI Model Catalog.
59+
60+
We would utilise the above created model in the next steps to create the Model Deployment.
61+
62+
### Create Model deploy
63+
64+
* To deploy the model now in the console, navigate to your [OCI Data Science Project](https://cloud.oracle.com/data-science/project)
65+
* Select the project created earlier and then select `Model Deployment`
66+
* Click on `Create model deployment`
67+
* Under `Default configuration` set following custom environment variables
68+
* Key: `MODEL_DEPLOY_PREDICT_ENDPOINT`, Value: `/v1/completions`
69+
* Key: `MODEL_DEPLOY_HEALTH_ENDPOINT`, Value: `/v1/health/ready`
70+
* Key: `NIM_SERVER_PORT`, Value: `8080`
71+
* Key: `SHM_SIZE`, Value: `10g`
72+
* Key: `NIM_MODEL_NAME`, Value: `/opt/ds/model/deployed_model`
73+
* Key: `OPENSSL_FORCE_FIPS_MODE`, Value: `0`
74+
* Under `Models` click on the `Select` button and select the Model Catalog entry we created earlier
75+
* Under `Compute` and then `Specialty and previous generation` select the `VM.GPU.A10.2` instance
76+
* Under `Networking` choose the `Default Networking` option.
77+
* Under `Logging` select the Log Group where you've created your predict and access log and select those correspondingly
78+
* Select the custom container option `Use a Custom Container Image` and click `Select`
79+
* Select the OCIR repository and image we pushed earlier
80+
* Leave the ports as the default port is 8080.
81+
* Leave CMD and Entrypoint as blank.
82+
* Click on `Create` button to create the model deployment
83+
84+
* Once the model is deployed and shown as `Active`, you can execute inference against it.
85+
* Go to the model you've just deployed and click on it
86+
* Under the left side under `Resources` select `Invoking your model`
87+
* You will see the model endpoint under `Your model HTTP endpoint` copy it.
88+
89+
## Inference
90+
91+
```bash
92+
oci raw-request \
93+
--http-method POST \
94+
--target-uri <MODEL-DEPLOY-ENDPOINT> \
95+
--request-body '{"model": "/opt/ds/model/deployed_model", "messages": [ { "role":"user", "content":"Hello! How are you?" }, { "role":"assistant", "content":"Hi! I am quite well, how can I help you today?" }, { "role":"user", "content":"Can you write me a song?" } ], "top_p": 1, "n": 1, "max_tokens": 200, "stream": false, "frequency_penalty": 1.0, "stop": ["hello"] }' \
96+
--auth resource_principal
97+
```
98+
99+
## Troubleshooting
100+
101+
[Reference](https://github.com/oracle-samples/oci-data-science-ai-samples/tree/main/model-deployment/containers/llama2#troubleshooting)

model-deployment/containers/nim/README-vanilla-containers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ Use any zip file to create a dummy model artifact. As we will be downloading mod
7070
* Key: `STORAGE_SIZE_IN_GB`, Value: `120`
7171
* Key: `NCCL_CUMEM_ENABLE`, Value: `0`
7272
* Key: `WEB_CONCURRENCY`, Value: `1`
73+
* Key: `NGC_API_KEY`, Value: `<KEY_GENERATED_FROM_NGC>`
7374
* Under `Models` click on the `Select` button and select the Model Catalog entry we created earlier
7475
* Under `Compute` and then `Specialty and previous generation` select the `VM.GPU.A10.2` instance
7576
* Under `Networking` choose the `Custom Networking` option and bring the VCN and subnet, which allows Internet access.
7677
* Under `Logging` select the Log Group where you've created your predict and access log and select those correspondingly
7778
* Select the custom container option `Use a Custom Container Image` and click `Select`
7879
* Select the OCIR repository and image we pushed earlier
7980
* Leave the ports as the default port is 8080.
80-
* Leave CMD as below and Entrypoint as blank. Use `Add parameter` and populate each text field with comma separated values -
81-
`python3, -m, vllm_nvext.entrypoints.openai.api_server, --enforce-eager, --gpu-memory-utilization, 0.85, --max-model-len, 2048`
81+
* Leave CMD and Entrypoint as blank.
8282
* Click on `Create` button to create the model deployment
8383
8484
* Once the model is deployed and shown as `Active`, you can execute inference against it.

0 commit comments

Comments
 (0)