Step-by-step guide to compiling and deploying Stable Diffusion XL on AWS Inferentia2 using Amazon SageMaker and the optimum-neuron library. Covers model conversion to Neuron format, creating a custom inference.py script, uploading artifacts to S3, deploying a real-time SageMaker endpoint, and running image generation. The setup achieves ~6 seconds per image on an inf2.xlarge instance at $0.99/hour, translating to roughly $0.0016 per generated image — positioning Inferentia2 as a cost-effective GPU alternative for inference workloads.

6m read timeFrom philschmid.de
Post cover image
Table of contents
Quick intro: AWS Inferentia 21. Convert Stable Diffusion to AWS Neuron (Inferentia2) with optimum-neuron2. Create a custom inference.py script for Stable Diffusion3. Upload the neuron model and inference script to Amazon S34. Deploy a Real-time Inference Endpoint on Amazon SageMakerConclusion