kumahiyo commited on
Commit
dc6ab6b
1 Parent(s): fdee321

add cuda settings

Browse files
Files changed (4) hide show
  1. Dockerfile +2 -0
  2. main.py +3 -3
  3. requirements.txt +0 -1
  4. requirements_cuda.txt +4 -0
Dockerfile CHANGED
@@ -5,9 +5,11 @@ FROM python:3.9
5
  WORKDIR /code
6
 
7
  # Copy the current directory contents into the container at /code
 
8
  COPY ./requirements.txt /code/requirements.txt
9
 
10
  # Install requirements.txt
 
11
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
12
 
13
  # Set up a new user named "user" with user ID 1000
 
5
  WORKDIR /code
6
 
7
  # Copy the current directory contents into the container at /code
8
+ COPY ./requirements_cuda.txt /code/requirements_cuda.txt
9
  COPY ./requirements.txt /code/requirements.txt
10
 
11
  # Install requirements.txt
12
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements_cuda.txt
13
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
14
 
15
  # Set up a new user named "user" with user ID 1000
main.py CHANGED
@@ -37,9 +37,9 @@ def draw(data: Data):
37
 
38
  model_id = 'stabilityai/stable-diffusion-2'
39
 
40
- #pipe = StableDiffusionPipeline.from_pretrained(model_id, revision='fp16', torch_dtype=torch.float16)
41
- pipe = StableDiffusionPipeline.from_pretrained(model_id)
42
- #pipe = pipe.to('cuda')
43
 
44
  image = pipe(prompt, negative_prompt=n_prompt).images[0]
45
 
 
37
 
38
  model_id = 'stabilityai/stable-diffusion-2'
39
 
40
+ #pipe = StableDiffusionPipeline.from_pretrained(model_id)
41
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, revision='fp16', torch_dtype=torch.float16)
42
+ pipe = pipe.to('cuda')
43
 
44
  image = pipe(prompt, negative_prompt=n_prompt).images[0]
45
 
requirements.txt CHANGED
@@ -1,7 +1,6 @@
1
  fastapi==0.74.*
2
  requests==2.27.*
3
  sentencepiece==0.1.*
4
- torch==1.11.*
5
  transformers==4.*
6
  uvicorn[standard]==0.17.*
7
  diffusers[torch]==0.13.*
 
1
  fastapi==0.74.*
2
  requests==2.27.*
3
  sentencepiece==0.1.*
 
4
  transformers==4.*
5
  uvicorn[standard]==0.17.*
6
  diffusers[torch]==0.13.*
requirements_cuda.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ --extra-index-url https://download.pytorch.org/whl/cu117
2
+ torch
3
+ torchvision
4
+ torchaudio