File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import sys
2+ import os
3+ from .lib import getMinio , getDDA
4+ from test import runTest
5+
6+
7+ def test_memory ():
8+ return
9+ """
10+ Make sure when switching models we release VRAM afterwards.
11+ """
12+ HOME = os .getenv ("HOME" )
13+ dda = dda = getDDA (
14+ # minio=minio
15+ # stream_logs=True,
16+ volumes = [f"{ HOME } /root-cache:/root/.cache" ],
17+ )
18+ print (dda )
19+
20+ TEST_ARGS = {"test_url" : dda .url }
21+ MODEL_ARGS = {"num_infernece_steps" : 1 }
22+
23+ mem_usage = list ()
24+
25+ # 768x768 model is obviously bigger
26+ result = runTest (
27+ "txt2img" ,
28+ TEST_ARGS ,
29+ {
30+ "MODEL_ID" : "stabilityai/stable-diffusion-2-1" , # not -base
31+ "MODEL_REVISION" : "fp16" ,
32+ "MODEL_PRECISION" : "fp16" ,
33+ "MODEL_URL" : "s3://" ,
34+ },
35+ MODEL_ARGS ,
36+ )
37+ print (result )
38+ mem_usage .append (result ["$mem_usage" ])
39+
40+ # 512x512 model is obviously bigger
41+ result = runTest (
42+ "txt2img" ,
43+ TEST_ARGS ,
44+ {
45+ "MODEL_ID" : "stabilityai/stable-diffusion-2-1-base" , # <--
46+ "MODEL_REVISION" : "fp16" ,
47+ "MODEL_PRECISION" : "fp16" ,
48+ "MODEL_URL" : "s3://" ,
49+ },
50+ MODEL_ARGS ,
51+ )
52+ print (result )
53+ mem_usage .append (result ["$mem_usage" ])
54+
55+ print ({"mem_usage" : mem_usage })
56+ assert mem_usage [1 ] < mem_usage [0 ]
57+
58+ dda .stop ()
You can’t perform that action at this time.
0 commit comments