Chapter 5. Serving and inferencing with Podman using AMD ROCm AI accelerators
Serve and inference a large language model with Podman and Red Hat AI Inference Server running on AMD ROCm AI accelerators.
Prerequisites
- You have installed Podman or Docker.
- You are logged in as a user with sudo access.
-
You have access to
registry.redhat.ioand have logged in. - You have a Hugging Face account and have generated a Hugging Face access token.
You have access to a Linux server with data center grade AMD ROCm AI accelerators installed.
For AMD GPUs:
For more information about supported vLLM quantization schemes for accelerators, see Supported hardware.
Procedure
Open a terminal on your server host, and log in to
registry.redhat.io:podman login registry.redhat.io
$ podman login registry.redhat.ioCopy to Clipboard Copied! Toggle word wrap Toggle overflow Pull the AMD ROCm image by running the following command:
podman pull registry.redhat.io/rhaiis/vllm-rocm-rhel9:3.3.0
$ podman pull registry.redhat.io/rhaiis/vllm-rocm-rhel9:3.3.0Copy to Clipboard Copied! Toggle word wrap Toggle overflow If your system has SELinux enabled, configure SELinux to allow device access:
sudo setsebool -P container_use_devices 1
$ sudo setsebool -P container_use_devices 1Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a volume and mount it into the container. Adjust the container permissions so that the container can use it.
mkdir -p rhaiis-cache
$ mkdir -p rhaiis-cacheCopy to Clipboard Copied! Toggle word wrap Toggle overflow chmod g+rwX rhaiis-cache
$ chmod g+rwX rhaiis-cacheCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create or append your
HF_TOKENHugging Face token to theprivate.envfile. Source theprivate.envfile.echo "export HF_TOKEN=<your_HF_token>" > private.env
$ echo "export HF_TOKEN=<your_HF_token>" > private.envCopy to Clipboard Copied! Toggle word wrap Toggle overflow source private.env
$ source private.envCopy to Clipboard Copied! Toggle word wrap Toggle overflow Start the AI Inference Server container image.
For AMD ROCm accelerators:
Use
amd-smi static -ato verify that the container can access the host system GPUs:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Where:
--group-add keep-groups-
Preserves the supplementary groups from the host user. On AMD systems, you must belong to both the
videoandrendergroups to access GPUs.
Start the container:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Where:
--security-opt=label=disable- Disables SELinux label relabeling for volume mounts. Without this option, the container might fail to start.
--shm-size=4GB -p 8000:8000-
Specifies the shared memory size and port mapping. Increase
--shm-sizeto8GBif you experience shared memory issues. --tensor-parallel-size 2- Specifies the number of GPUs to use for tensor parallelism. Set this value to match the number of available GPUs.
Verification
In a separate tab in your terminal, make a request to the model with the API.
curl -X POST -H "Content-Type: application/json" -d '{ "prompt": "What is the capital of France?", "max_tokens": 50 }' http://<your_server_ip>:8000/v1/completions | jqcurl -X POST -H "Content-Type: application/json" -d '{ "prompt": "What is the capital of France?", "max_tokens": 50 }' http://<your_server_ip>:8000/v1/completions | jqCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow