Add docker image server
This commit is contained in:
parent
dc8731ca60
commit
fb360056fc
12
README.md
12
README.md
|
@ -8,5 +8,15 @@ https://github.com/alphacep/vosk-server
|
|||
|
||||
https://huggingface.co/CompVis/stable-diffusion-v1-4
|
||||
|
||||
https://discuss.pytorch.org/t/need-help-trouble-with-cuda-capability-sm-86/120235/36
|
||||
https://discuss.pytorch.org/t/need-help-trouble-with-cuda-capability-sm-86/120235/38
|
||||
|
||||
```
|
||||
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
|
||||
&& curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
|
||||
&& curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
|
||||
```
|
||||
|
||||
```
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y nvidia-docker2
|
||||
```
|
|
@ -0,0 +1,10 @@
|
|||
version: '3.9'
|
||||
|
||||
services:
|
||||
imageserver:
|
||||
image: imageserver
|
||||
build: imageserver
|
||||
runtime: nvidia
|
||||
command: python3 /main.py
|
||||
env_file:
|
||||
- .env
|
|
@ -0,0 +1,8 @@
|
|||
FROM nvidia/cuda:11.6.0-base-ubuntu20.04
|
||||
RUN apt-get update && apt-get install python3 python3-pip -y
|
||||
|
||||
RUN pip3 install --upgrade diffusers transformers scipy python-dotenv cuda-python && \
|
||||
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117 && \
|
||||
pip install torch==1.11.0+cu115 torchvision==0.12.0+cu115 torchaudio==0.11.0+cu115 -f https://download.pytorch.org/whl/torch_stable.html
|
||||
|
||||
COPY main.py /main.py
|
|
@ -0,0 +1,19 @@
|
|||
import torch
|
||||
import uuid
|
||||
import os
|
||||
from diffusers import StableDiffusionPipeline
|
||||
from dotenv import load_dotenv
|
||||
from os import getenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# get your token at https://huggingface.co/settings/tokens
|
||||
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", revision="fp16", torch_dtype=torch.float16, use_auth_token=getenv("TOKEN"))
|
||||
pipe.to("cuda")
|
||||
|
||||
prompt = "metal buttons are often soldiers who just got out of high school or a couple of years graduated from college easy as an air conditioned box about radar the patriot radar known as the a n n e e e pi this is an extremely powerful radar unit so powerful that they actually"
|
||||
|
||||
for _ in range(10):
|
||||
image = pipe(prompt)["sample"][0]
|
||||
|
||||
image.save(f"{uuid.uuid4()}.png".replace(" ", "_"))
|
Loading…
Reference in New Issue