|
1 | | -# Provision of Nvidia Container |
| 1 | +# Provision of NVIDIA Container |
2 | 2 |
|
3 | 3 | ## Introduction |
4 | 4 |
|
5 | | -This lab will take you through the steps needed to provision Nvidia container on oci instance with an A10 shape which has GPU, |
| 5 | +This lab will take you through the steps needed to provision NVIDIA container on oci instance with an A10 shape which has GPU, |
6 | 6 |
|
7 | 7 | Estimated Time: 45 minutes |
8 | 8 |
|
9 | | -### About NVIDIA cuOpt |
10 | | - |
11 | | -NVIDIA cuOpt is an optimization tool that specializes in routing. It is run as a microservice in the cloud using the container provided. The cuOpt microservice leverages OpenAPI standards, serving endpoints running on port 5000 (by default) to accept optimization input data and return optimized routing solutions. |
12 | | - |
13 | 9 | ### Objectives |
14 | 10 |
|
15 | | -Provisioning of Nvidia container |
| 11 | +Provisioning of NVIDIA container |
16 | 12 |
|
17 | 13 | ### Prerequisites |
18 | 14 |
|
19 | 15 | This lab assumes you have: |
20 | 16 |
|
21 | 17 | * An Oracle account |
22 | | -* Administrator permissions or permissions to use the OCI Compute, Identity Domains, A10 images, NGC API Key. |
| 18 | +* Administrator permissions or permissions to use the OCI Compute, Identity Domains, A10 shapes available. |
23 | 19 |
|
24 | 20 | ## Task 1: Launch an A10 instance |
25 | 21 |
|
26 | 22 | 1. Go to Compute -> Instance -> Create Instance. Under Image and Shape choose A10 shape as shown in the image below. |
27 | 23 |
|
28 | | -  |
29 | | - |
30 | | -2. Click on Change Image and select Gen2-GPU-2024 (one on the top) as Image Build under Oracle Linux 8. Shown in the image below. |
| 24 | +  |
31 | 25 |
|
32 | | -  |
| 26 | +2. Click on Change Image and select the latest GPU version (one on the top) as Image Build under Oracle Linux 8. Shown in the image below. |
33 | 27 |
|
34 | | -3. Provide the information for **VCN**, **Subnet (It has to be Public)**, **Add SSH Keys (Add keys to access your instance)** |
| 28 | +  |
35 | 29 |
|
36 | | -Click **Create** |
| 30 | +3. Provide the information for **VCN**, **Subnet (It has to be Public)**, **Add SSH Keys (Add keys to access your instance)** and click **Create**. |
37 | 31 |
|
38 | | - |
| 32 | +  |
39 | 33 |
|
40 | | -## Task 2: Run Nvidia Container |
| 34 | +## Task 2: Install NVIDIA container toolkit |
41 | 35 |
|
42 | 36 | 1. In few minutes the status of recently created instance will change from **Provisioning** to **Running**. |
43 | 37 |
|
44 | | -2. Access the instance using the public ip of the instance with the following command 'ssh -i <ssh_key> opc@public_ip'. |
| 38 | +2. Access the instance using the public ip of the instance with the following command: |
45 | 39 |
|
46 | | -3. Install nvidia-container-toolkit |
| 40 | + ```text |
| 41 | + <copy> |
| 42 | + ssh -i <ssh_key> opc@public_ip |
| 43 | + </copy> |
| 44 | + ``` |
| 45 | +
|
| 46 | +5. Install NVIDIA-container-toolkit |
47 | 47 |
|
48 | 48 | ```text |
49 | 49 | <copy> |
50 | | - curl -s -L https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo | sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo |
| 50 | + curl -s -L https://nvidia.github.io/libNVIDIA-container/stable/rpm/nvidia-container-toolkit.repo | sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo |
51 | 51 | </copy> |
52 | 52 | ``` |
53 | 53 |
|
54 | | -4. Run the following command |
| 54 | +6. Run the following command |
55 | 55 |
|
56 | 56 | ```text |
57 | 57 | <copy> |
58 | 58 | sudo yum install -y nvidia-container-toolkit |
59 | 59 | </copy> |
60 | 60 | ``` |
61 | 61 |
|
62 | | -5. Generate CDI configuration for podman |
| 62 | +7. Generate CDI configuration for podman |
63 | 63 |
|
64 | 64 | ```text |
65 | 65 | <copy> |
66 | 66 | sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml |
67 | 67 | </copy> |
68 | 68 | ``` |
69 | 69 |
|
70 | | -6. Setup nvidia driver to be persistent across reboots |
| 70 | +8. Setup NVIDIA driver to be persistent across reboots |
71 | 71 |
|
72 | 72 | ```text |
73 | 73 | <copy> |
74 | 74 | sudo nvidia-persistenced |
75 | 75 | </copy> |
76 | 76 | ``` |
77 | 77 |
|
78 | | -7. Run the following command. |
| 78 | +9. Run the following command. |
79 | 79 |
|
80 | 80 | ```text |
81 | 81 | <copy> |
82 | 82 | sudo systemctl enable nvidia-persistenced |
83 | 83 | </copy> |
84 | 84 | ``` |
85 | 85 |
|
86 | | -8. Install podman |
87 | | -
|
88 | | -```text |
89 | | - <copy> |
90 | | - sudo dnf module install -y container-tools:ol8 |
91 | | - </copy> |
92 | | -``` |
93 | | - |
94 | | -9. Allow containers to use device files |
95 | | - |
96 | | -```text |
97 | | - <copy> |
98 | | - sudo setsebool -P container_use_devices 1 |
99 | | - </copy> |
100 | | -``` |
101 | | - |
102 | | -```text |
103 | | - <copy> |
104 | | - sudo setsebool -P container_manage_cgroup on |
105 | | - </copy> |
106 | | -``` |
107 | | - |
108 | | -## Task 3: Generate NGC API Key |
109 | | - |
110 | | -Follow the steps listed in the following link to generate an api key which will be used in next task. [NGC API Key](https://docs.nvidia.com/ai-enterprise/deployment-guide-spark-rapids-accelerator/0.1.0/appendix-ngc.html) |
111 | | - |
112 | | -## Task 4: Continue with Steps to run the container |
113 | | - |
114 | | -1. Login to nvcr.io. Use the api key generated in previous step. |
| 86 | +10. Install podman |
115 | 87 |
|
116 | 88 | ```text |
117 | 89 | <copy> |
118 | | - sudo podman login nvcr.io --username '$oauthtoken' --password $api_key |
| 90 | + sudo dnf module install -y container-tools:ol8 |
119 | 91 | </copy> |
120 | 92 | ``` |
121 | 93 |
|
122 | | -2. Pull cuopt from nvcr.io |
| 94 | +9. Allow containers to use device files |
123 | 95 |
|
124 | 96 | ```text |
125 | 97 | <copy> |
126 | | - sudo podman pull nvcr.io/nvidia/cuopt/cuopt:25.08 |
| 98 | + sudo setsebool -P container_use_devices 1 |
127 | 99 | </copy> |
128 | 100 | ``` |
129 | 101 |
|
130 | | -3. Create systemd service file for cuopt |
131 | | -
|
132 | 102 | ```text |
133 | 103 | <copy> |
134 | | - sudo tee /etc/systemd/system/cuopt.service <<EOF |
135 | | - [Unit] |
136 | | - Description=Podman cuopt Container |
137 | | - After=network.target |
138 | | - [Service] |
139 | | - Type=simple |
140 | | - Restart=always |
141 | | - ExecStart=/usr/bin/podman run --rm --device nvidia.com/gpu=all -p 5000:5000 nvcr.io/nvidia/cuopt/cuopt:25.08 |
142 | | - [Install] |
143 | | - WantedBy=multi-user.target |
144 | | - EOF |
| 104 | + sudo setsebool -P container_manage_cgroup on |
145 | 105 | </copy> |
146 | 106 | ``` |
147 | 107 |
|
148 | | -4. Reload systemd and start the service |
| 108 | +## Task 3: Run NVIDIA cuOpt container |
149 | 109 |
|
150 | | - ```text |
151 | | - <copy> |
152 | | - sudo systemctl daemon-reload |
153 | | - </copy> |
154 | | - ``` |
| 110 | +1. Run the cuopt image |
155 | 111 |
|
156 | 112 | ```text |
157 | 113 | <copy> |
158 | | - sudo systemctl start cuopt.service |
| 114 | + sudo podman run --rm --device nvidia.com/gpu=all -p 8000:8000 -e CUOPT_SERVER_PORT=8000 docker.io/nvidia/cuopt:latest-cuda12.8-py3.12 |
159 | 115 | </copy> |
160 | 116 | ``` |
161 | 117 |
|
162 | | -5. Enable automatic start on boot |
| 118 | +## Task 4: Test cuOpt with an API call |
163 | 119 |
|
164 | | - ```text |
| 120 | +Open a new SSH session with the following command (leave the previous one open so you will be able to see cuOpt logs): |
| 121 | +
|
| 122 | +```text |
165 | 123 | <copy> |
166 | | - sudo systemctl enable cuopt.service |
| 124 | + ssh -i <ssh_key> opc@public_ip -L 8000:localhost:8000 |
167 | 125 | </copy> |
168 | | - ``` |
| 126 | +``` |
| 127 | +```text |
| 128 | + <copy> |
| 129 | + curl --location 'http://localhost:8000/cuopt/request' \ |
| 130 | + --header 'Content-Type: application/json' \ |
| 131 | + --header 'Accept: application/json' \ |
| 132 | + --data '{ |
| 133 | + "cost_matrix_data": { "data": { "0": [[0, 1], [1, 0]] } }, |
| 134 | + "task_data": { |
| 135 | + "task_locations": [1], |
| 136 | + "demand": [[1]], |
| 137 | + "task_time_windows": [[0, 10]], |
| 138 | + "service_times": [1] |
| 139 | + }, |
| 140 | + "fleet_data": { |
| 141 | + "vehicle_locations": [[0, 0]], |
| 142 | + "capacities": [[2]], |
| 143 | + "vehicle_time_windows": [[0, 20]] |
| 144 | + }, |
| 145 | + "solver_config": { "time_limit": 1 } |
| 146 | + }' |
| 147 | + </copy> |
| 148 | +``` |
169 | 149 |
|
170 | | -## Task 5: Test cuOpt with an API call |
171 | 150 |
|
172 | | -Run the following command to test the container |
| 151 | +You will receive a reqId. Now run the following command, and you should see that the request has been completed: |
173 | 152 |
|
174 | 153 | ```text |
175 | | - <copy> |
176 | | - curl --location 'http://0.0.0.0:5000/cuopt/routes' \ |
177 | | - --header 'Content-Type: application/json' \ |
178 | | - --header "CLIENT-VERSION: custom" \ |
179 | | - -d '{ |
180 | | - "cost_matrix_data": {"data": {"0": [[0, 1], [1, 0]]}}, |
181 | | - "task_data": {"task_locations": [1], "demand": [[1]], "task_time_windows": [[0, 10]], "service_times": [1]}, |
182 | | - "fleet_data": {"vehicle_locations":[[0, 0]], "capacities": [[2]], "vehicle_time_windows":[[0, 20]] }, |
183 | | - "solver_config": {"time_limit": 2} |
184 | | - }' |
185 | | - </copy> |
| 154 | + <copy> |
| 155 | + curl --location 'http://localhost:8000/cuopt/result/YOUR_REQUEST_ID' \ |
| 156 | + --header 'Accept: application/json' |
| 157 | + </copy> |
186 | 158 | ``` |
187 | 159 |
|
| 160 | +## Task 5: Discover the cuOpt documentation |
| 161 | + |
| 162 | +On your local machine, go to [http://localhost:8000/cuopt/docs](http://localhost:8000/cuopt/docs), where you can also run multiple tests. |
| 163 | + |
188 | 164 | ## Acknowledgements |
189 | 165 |
|
190 | 166 | **Authors** |
191 | 167 |
|
192 | 168 | * **Guido Alejandro Ferreyra**, Principal Cloud Architect, NACIE |
193 | | -* **Abhinav Jain**, Senior Cloud Engineer, NACIE |
194 | 169 |
|
195 | 170 | **Last Updated By/Date:** |
196 | | -* **Abhinav Jain**, Senior Cloud Engineer, NACIE, August 2025 |
| 171 | +* **Guido Alejandro Ferreyra**, Principal Cloud Architect, NACIE, December 2025 |
0 commit comments