- Introduction
- What is ByteNite?
- Project Structure
- CPU vs. GPU Versions
- Prerequisites (If you've already onboarded to ByteNite, you can skip this section!)
- Installing the ByteNite Developer CLI
- App Components
- Running Jobs on ByteNite
- Example: Image Generation with Stable Diffusion
- Troubleshooting & FAQ
- References
This repository provides a robust, scalable image generation pipeline designed to run on ByteNite’s distributed, serverless container platform. It supports both CPU and GPU execution, enabling parallelized image generation at scale with minimal infrastructure configuration. For CPU-based workloads, the pipeline uses the Hugging Face diffusers library to perform Stable Diffusion inference, while GPU-based executions leverage the high-performance Flux model for faster generation.
ByteNite is a serverless container platform for stateless, compute-intensive workloads. It abstracts away cloud infrastructure, letting you focus on your application logic. ByteNite provides:
- Near-instant startup times and flexible compute
- Distributed execution fabric (native fan-in/fan-out logic)
- Modular building blocks: Partitioners, Apps, Assemblers
- Simple job submission via CLI or API
img-gen-diffusers/
├── fanout-replica/ # Partitioner engine
│ ├── manifest.json
│ └── app/
│ └── main.py
├── img-gen-diffusers-flux-gpu/ # GPU-optimized app
│ ├── manifest.json
│ ├── buildx-flux-schnell-w-token.sh
│ ├── Dockerfile
│ └── app/
│ └── main.py
├── img-gen-diffusers-notaai-cpu/ # CPU-optimized app
│ ├── manifest.json
│ └── app/
│ └── main.py
├── zipper/ # Assembler engine
│ ├── manifest.json
│ └── app/
│ └── main.py
├── templates/ # Job templates
│ ├── img-gen-diffusers-flux-gpu-template.json
│ └── img-gen-diffusers-notaai-cpu-template.json
└── README.md
- CPU Version (
img-gen-diffusers-notaai-cpu): Runs on high-core-count CPUs (recommended: 16+ vCPUs, 32GB+ RAM). Suitable for environments without GPU access or for cost-effective batch jobs. - GPU Version (
img-gen-diffusers-flux-gpu): Runs on general-purpose and high-end GPUs. Optimized for CUDA-enabled devices, with support for advanced GPU features and larger batch sizes. Recommended for faster inference and large-scale jobs.
Both versions use the same core logic and can be deployed interchangeably depending on your hardware requirements.
Already onboarded to ByteNite?
If you’ve already created an account, set up payment, and installed the CLI for a previous app, you can skip this section and jump straight to Installing the ByteNite Developer CLI or the next relevant step.
👤 Create an account
- You will need to Request an Access Code and fill out the resulting form with your contact info.
- Once recieveing your access code, you will be able to sign up on the computing platform.
💳 Add a payment method
- Once logged into the platform, go to the Billing Page (can also access by clicking into the Billing tab in the sidebar).
- Locate the Payment Info card and navigate to the Customer Portal. Add a payment method to your account through Stripe.
- Your payment info is used for manual and automatic top-ups. Ensure you have enough funds to avoid service interruptions.
🪙 Redeem ByteChips
- If you have a coupon code, redeem it on your billing page to add ByteChips (credits) to your balance.
- Go to the Account Balance card and click "Redeem". Enter your coupon code and complete the process. Refresh to confirm the balance.
- We'd love to get you started with free credits to test our platform, contact ByteNite support to request some.
For CLI/SDK Users (Recommended)
Most users should use the CLI/SDK for the easiest experience:
- Download and install the ByteNite Developer CLI (see below for instructions by OS).
- Authenticate by running:
This will open a browser window for secure login.
bytenite auth
- Once authenticated, you can use all
byteniteCLI commands to manage apps, engines, templates, and jobs.
For API Users (Advanced/Programmatic Access)
If you plan to use the ByteNite API directly (e.g., with Postman or custom scripts), you’ll need an API key and access token:
🔐 Get an API key
- Go to your ByteNite profile or click your profile avatar (top right).
- Click New API Key, configure its settings, and enter the confirmation code sent to your email.
- Copy your API key immediately and store it securely. You will not be able to view it again.
- If a key is no longer needed or is compromised, revoke it from your profile.
🔑 Get an access token
- An access token is required to authenticate all requests to the ByteNite API (including Postman).
- Request an access token from the Access Token endpoint using your API key. Tokens last 1 hour by default.
- See the API Reference for details and example requests.
🛠️ Set up development tools
- Python 3.8+ for local development or running scripts.
- Git (to clone this repository)
- (Optional) Docker if you plan to build custom containers.
Add the ByteNite repository:
echo "deb [trusted=yes] https://storage.googleapis.com/bytenite-prod-apt-repo/debs ./" | sudo tee /etc/apt/sources.list.d/bytenite.listUpdate package lists:
sudo apt updateInstall the ByteNite CLI:
sudo apt install byteniteTroubleshooting:
- Update your system:
sudo apt update && sudo apt upgrade - Verify repository:
cat /etc/apt/sources.list.d/bytenite.list - Check package:
apt search bytenite
Add the ByteNite tap:
brew tap ByteNite2/bytenite-dev-cli https://github.com/ByteNite2/bytenite-dev-cli.gitInstall the CLI:
brew install byteniteUpdate Homebrew:
brew updateUpgrade ByteNite CLI:
brew upgrade byteniteDownload and run the latest Windows release from the ByteNite CLI GitHub page.
Check the CLI version:
bytenite versionAuthenticate with OAuth2:
bytenite authThis opens a browser for login. Credentials are stored at:
- Linux:
$HOME/.config/bytenite-cli/auth-prod.json - Mac:
/Users/[user]/Library/Application Support/bytenite-cli/auth-prod.json
Follow these steps to get up and running with your own ByteNite image generation pipeline:
-
Clone this repository to your own machine:
git clone <your-fork-or-this-repo-url> && \ cd img-gen-diffusers
-
(Optional but recommended) Fork this repo to your own GitHub account.
-
Install the ByteNite Developer CLI (see instructions above for your OS).
-
Authenticate with ByteNite:
bytenite auth
-
Push the apps and engines to your ByteNite account:
bytenite app push ./img-gen-diffusers-notaai-cpu && \ bytenite app push ./img-gen-diffusers-flux-gpu && \ bytenite engine push ./fanout-replica && \ bytenite engine push ./zipper
-
Activate the apps and engines:
bytenite app activate img-gen-diffusers-notaai-cpu && \ bytenite app activate img-gen-diffusers-flux-gpu && \ bytenite engine activate fanout-replica && \ bytenite engine activate zipper
-
Push the job templates:
bytenite template push ./templates/img-gen-diffusers-notaai-cpu-template.json && \ bytenite template push ./templates/img-gen-diffusers-flux-gpu-template.json -
Launch a job using the API (we have a handy Postman collection ready for you). (GPU Job Postman collection or CPU Job Postman collection) or proceed with the methods described below.
Note: If using Postman, you’ll need to generate an access token with your API key and include it in the
Authorizationheader for all requests.
Run the help command to see all options:
bytenite --helpMost users only need these commands in order:
bytenite app push [app_folder]bytenite app activate [app_tag]bytenite engine push [engine_folder]bytenite engine activate [engine_tag]bytenite template push [template_filepath]bytenite app status [app_tag](to check status)
For more commands, run bytenite --help or see the ByteNite documentation.
- Implements image generation using Hugging Face diffusers (Stable Diffusion).
- Accepts a prompt and outputs an image file.
- See
main.pyfor implementation details.
- Splits the job into multiple parallel tasks (replicas).
- Each replica generates an image from the same or different prompts.
- See
fanout-replica/app/main.pyfor logic.
- Templates link your app, partitioner, and (optionally) assembler.
- Example (CPU):
templates/img-gen-diffusers-notaai-cpu-template.json - Example (GPU):
templates/img-gen-diffusers-flux-gpu-template.json
You can use our ready-made Postman collections to streamline your job launching (GPU Job Postman collection or CPU Job Postman collection) or proceed with the methods described below.
-
Get an access token:
import requests response = requests.post( "https://api.bytenite.com/v1/auth/access_token", json={"apiKey": "<YOUR_API_KEY>"} ) token = response.json()["token"]
-
Create a job:
response = requests.post( "https://api.bytenite.com/v1/customer/jobs", headers={"Authorization": token}, json={"name": "img-gen-job", "templateId": "img-gen-diffusers-flux-gpu-template"} ) jobId = response.json()["job"]["id"]
-
Set data source/destination:
response = requests.patch( f"https://api.bytenite.com/v1/customer/jobs/{jobId}/datasource", headers={"Authorization": token}, json={ "dataSource": {"dataSourceDescriptor": "bypass"}, "dataDestination": {"dataSourceDescriptor": "bucket"} } )
-
Set parameters:
response = requests.patch( f"https://api.bytenite.com/v1/customer/jobs/{jobId}/params", headers={"Authorization": token}, json={ "partitioner": {"num_replicas": 5}, "app": {"prompt": "A photorealistic sunset over the ocean"} } )
-
Run the job:
response = requests.post( f"https://api.bytenite.com/v1/customer/jobs/{jobId}/run", headers={"Authorization": token}, json={"taskTimeout": 3600, "jobTimeout": 86400, "isTestJob": True} )
- Launch a job with the prompt of your choice and desired number of replicas.
- Each task will generate an image and save it to a temporary output bucket for your retrieval.
- Once your job has completed, you will recieve a downloadable link to your zipped file of outputs
- Results and logs can be accessed via the ByteNite UI or API.
- App fails to start: Check your container image and manifest.json for correct dependencies and entrypoint.
- No output images: Ensure the output path in
main.pymatches ByteNite’s expected results directory. - Resource errors: Increase
min_cpu/min_memoryor use the GPU version for heavy workloads. - Authentication issues: Regenerate your API key and access token.
- See ByteNite Docs FAQ for more.
For questions or support, please open an issue or contact the ByteNite team via the official docs.