![](/_next/image?url=https%3A%2F%2Fassets.ngc.nvidia.com%2Fproducts%2Fapi-catalog%2Fimages%2Fnvidia-cuopt.jpg&w=3840&q=75)
nvidia/cuopt
RUN ANYWHERE
World-record accuracy and performance for complex route optimization.
By running the below commands, you accept the NVIDIA AI Enterprise Terms of Use and the NVIDIA Community Models License.
Pull and run nvidia/nvidia-cuopt
using Docker (this will download the full model and run it in your local environment)
$ docker login nvcr.io Username: $oauthtoken Password: <PASTE_API_KEY_HERE>
Start NIM
- Export
NGC_API_KEY
variable.
export NGC_API_KEY=<PASTE_API_KEY_HERE>
- Run the NIM container with the following commands.
docker run -it \ --gpus='"device=0"' \ -p 5000:5000 \ -e NGC_API_KEY \ nvcr.io/nvidia/cuopt/cuopt:24.07
This command will start the NIM container and expose port 5000 for the user to interact with the NIM.
- Open a new terminal, leaving the terminal open with the just launched service. In the new terminal, wait until the health check end point returns
{"status":"RUNNING","version":"24.07"}
before proceeding. This may take a couple of minutes. You can use the following command to query the health check.
curl http://localhost:5000/v2/health/ready
Python client example
- Save following Python example to a file named
nim_client.py
.
#!/usr/bin/env python3 import requests data = {"cost_matrix_data": {"data": {"0": [[0,1],[1,0]]}}, "task_data": {"task_locations": [0,1]}, "fleet_data": {"vehicle_locations": [[0,0],[0,0]]}} response = requests.post( url="http://localhost:5000/cuopt/routes", json=data ) response_body = response.json() print(response_body)
- Execute the example.
chmod +x nim_client.py ./nim_client.py
Shell client example
- Save the following Shell example to a file named
nim_client.sh
.
#!/usr/bin/env bash set -e URL=http://localhost:5000/cuopt/routes data='{"cost_matrix_data": {"data": {"0": [[0,1],[1,0]]}}, "task_data": {"task_locations": [0,1]}, "fleet_data": {"vehicle_locations": [[0,0],[0,0]]}}' curl -H 'Content-Type: application/json' \ -d "$data" "$URL"
- Execute the example.
chmod +x nim_client.sh ./nim_client.sh
- The NIM displays the results to the terminal in JSON format. For more details on getting started with this NIM, visit the NVIDIA CUOPT Docs