When Cloud Meets Intelligence: Inference AI as a Service
Unlock the power of real-time decision making with inference AI as we guide you through the complexities of model deployment, using the Gcore platform as your roadmap.
Oct 10th, 2023 11:44am by
Image from Gcore.
Gcore sponsored this post.
AI Model Training and Inference
In the world of AI, there are two key operations: training and inference. Regular AI encompasses both of these tasks, learning from data and then making predictions or decisions based on that data. By contrast, inference AI focuses solely on the inference phase. After a model has been trained on a dataset, inference AI takes over to apply this model to new data to make immediate decisions or predictions. This specialization makes inference AI invaluable in time-sensitive applications, such as autonomous vehicles and real-time fraud detection, where making quick and accurate decisions is crucial. For self-driving cars, this service can swiftly analyze sensor data to make immediate driving decisions, eliminating latency and increasing safety. In real-time fraud detection, inference AI can instantaneously evaluate transactional data against historical patterns to flag or block suspicious activities.The Need for Streamlined AI Production Management
Managing AI production involves navigating a complex matrix of interconnected decisions and adjustments. From data center location to financial budgeting, each decision carries a ripple effect. In my experience as head of cloud operations at Gcore, I can say that this field is still defining its rules; the road from model training to deployment is more of a maze than a straight path. In this section, I’ll review the key components that every AI production manager must carefully consider to optimize performance and efficiency. Location and latency should be your first consideration in AI production. Choose the wrong data center location, and you’re setting yourself up for latency issues that can seriously degrade user experience. For example, if you’re operating in the EU but your data center is in the United States, the transatlantic data travel times can create noticeable delays — a non-starter for inference AI. Resource management demands real-time adaptability. Elements like CPUs, memory and specialized hardware — GPUs or TPUs — require constant tuning based on up-to-the-minute performance metrics. As you switch from development to full-scale production, dynamic resource management becomes not a luxury but a necessity, operating on a 24/7 cycle. Financial planning is tightly linked to operational efficiency. Accurate budget forecasts are crucial for long-term sustainability, particularly given the volatility of computational demands in response to user activity. Unlike the more mature landscape of software development, AI production management lacks a standardized playbook. This means you need to rely on bespoke expertise and be prepared for a higher error rate. It’s a field propelled by rapid innovation, and trial and error. In this sense, the sector is still in its adolescent phase — reckless, exciting and still figuring out its standards.How to Deploy an Inference AI Model
Now that we understand the key components of AI production management, let me walk you through a step-by-step guide for deploying an AI inference model, focusing on the integration of various tools and resources. The aim is to build an environment that ensures swift, efficient deployment and scaling. Here are some tools that will be essential for success:- Docker: An industry standard for containerization, aiding in the smooth deployment of your model.
- Whisper: A leading AI model for speech-to-text that serves as the foundation of our service.
- Simple Server Framework (SSF): This Graphcore tool facilitates the building and packaging (containerizing) of applications for serving.
- Harbor: An open source artifact storage software used for preserving Docker images, instrumental in our setup. Use the official docs to get set up.
Preparation
- Model: For this guide, we use a pre-trained model from Hugging Face. Training the model is outside the scope of this article.
- Environment: We have a designated cluster for model building. All commands will be executed via SSH.
Step 1: Set up a Virtual Environment
Create a virtual environment:
virtualenv .venv --prompt whisper:
source .venv/bin/activate
Step 2: Install Required Packages
Install SSF:
pip install https://github.com/graphcore/simple-server-framework/archive/refs/tags/v1.0.0.tar.gz
wget https://github.com/docker/buildx/releases/download/v0.11.2/buildx-v0.11.2.linux-amd64
mkdir -p ~/.docker/cli-plugins
mv buildx-v0.11.2.linux-amd64 ~/.docker/cli-plugins/docker-buildx
chmod u+x ~/.docker/cli-plugins/docker-buildx
Step 3: Codebase
Clone the Gcore repository that contains all the necessary files:
git clone https://github.com/G-Core/ai-code-examples.git
cd ai-code-examples && git checkout whisper-lux-small-ssf
26 endpoints:
27
28 - id: asr
29 version: 1
30 desc: Simple application interface for Whisper
31 custom: ~
32
33 inputs:
34
35 - id: file
36 type: TempFile
37 desc: Audio description text prompt
38
39 outputs:
40
41 - id: result
42 type: String
43 desc: Transcription of the text
- `build`: This is where the model’s computational graph is constructed. It must run on a host with an IPU.
- `startup`: Manages preliminary tasks before the model can begin serving user requests.
- `request`: This is the heart of the system, responsible for processing user requests.
- `shutdown`: Ensures graceful termination of the model, like completing ongoing requests.
- `is_healthy`: This method allows the model to function both as a standalone Docker container and as part of larger, more complex systems like Kubernetes.
Step 4: Building and Publishing the Container
Build and publish the container, specifying your own Docker registry address and credentials:
gc-ssf --config ssf_config.yaml build package publish --package-tag harbortest.cloud.gcorelabs.com/whisper/mkhl --docker-username gitlab --docker-password XXXXXXXXXX --container-server harbortest.cloud.gcorelabs.com
Step 5: Deploying to Edge Node
For deployment on the edge node, the following command is used:
gc-ssf --stdout-log-level DEBUG deploy --config ssf_config.yaml --deploy-platform Gcore --port 8100 --deploy-gcore-target-address ai-inference-cluster-1 --deploy-gcore-target-username ubuntu --docker-username gitlab --docker-password XXXXXXXXXXX --package-tag harbortest.cloud.gcorelabs.com/whisper/mkhl:latest --deploy-package --container-server harbortest.cloud.gcorelabs.com
Inferring a More Intelligent Future
Inference AI’s growing role isn’t limited to tech giants; it’s vital for any organization aiming for agility and competitiveness. Investment in this technology constitutes a strategic alignment with a scalable, evolving solution to the data deluge problem. Inference AI as a service is poised to become an indispensable business tool because it simplifies AI’s technical complexities, offering a scalable and streamlined way to sift through mountains of data and extract meaningful, actionable insights.How Gcore Uses Inference AI
Despite the surge in AI adoption, we recognize there’s still a gap in the market for specialized, out-of-the-box AI clusters that combine power with ease of deployment. Gcore is engineered to provide infrastructure and low latency services in order to go global faster. This solves one of the most significant challenges in the machine learning landscape: the transition from model development to scalable deployment. We use Graphcore’s Simple Server Framework to create an environment that’s capable not only of running machine learning models, but also of improving them continuously through Inference AI. For a deeper understanding of how Gcore is shaping the AI ecosystem, consider a visit to our blog and AI infrastructure documentation.
YOUTUBE.COM/THENEWSTACK
Tech moves fast, don't miss an episode. Subscribe to our YouTube
channel to stream all our podcasts, interviews, demos, and more.
