ford442 commited on
Commit
36df1f4
·
verified ·
1 Parent(s): c72e161

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -20
app.py CHANGED
@@ -7,26 +7,29 @@
7
  import spaces
8
  import os
9
 
10
- import subprocess
11
- subprocess.run(['sh', './conda.sh'])
12
 
13
- import sys
14
- conda_prefix = os.path.expanduser("~/miniconda3")
15
- conda_bin = os.path.join(conda_prefix, "bin")
16
 
17
  # Add Conda's bin directory to your PATH
18
- os.environ["PATH"] = conda_bin + os.pathsep + os.environ["PATH"]
19
 
20
  # Activate the base environment (adjust if needed)
21
- os.system(f'{conda_bin}/conda init --all')
22
- os.system(f'{conda_bin}/conda activate base')
 
 
23
  #os.system(f'{conda_bin}/conda install nvidia/label/cudnn-9.3.0::cudnn')
24
  #os.system(f'{conda_bin}/conda install nvidia/label/cuda-12.4.0::cuda-libraries')
25
  #os.system(f'{conda_bin}/conda install nvidia/label/cuda-12.4.0::cuda-libraries-dev')
26
  #os.system(f'{conda_bin}/conda install nvidia/label/cuda-12.4.0::cuda-cudart')
27
  #os.system(f'{conda_bin}/conda install nvidia/label/cuda-12.4.0::cuda-cudart-dev')
28
  #os.system(f'{conda_bin}/conda install nvidia/label/cuda-12.4.0::cuda-nvcc')
29
- os.system(f'{conda_bin}/conda install nvidia/label/cuda-12.4.0::cuda-toolkit')
 
30
 
31
  #subprocess.run(['pip', 'install', 'git+https://github.com/hidet-org/hidet.git'])
32
  #subprocess.run(['pip', 'install', 'git+https://github.com/ford442/hidet.git@thread'])
@@ -35,7 +38,7 @@ os.system(f'{conda_bin}/conda install nvidia/label/cuda-12.4.0::cuda-toolkit')
35
  #os.system(f'{conda_bin}/conda install rcdr_py37::tensorrt')
36
  #subprocess.run(['sh', './hidet.sh'])
37
  #subprocess.run(['sh', './modelopt.sh'])
38
- import hidet
39
  #print(dir(hidet))
40
  #import torch_tensorrt
41
 
@@ -54,8 +57,8 @@ import datetime
54
  import cyper
55
  from image_gen_aux import UpscaleWithModel
56
  import torch
57
- import torch._dynamo
58
- torch._dynamo.list_backends()
59
 
60
  torch.backends.cuda.matmul.allow_tf32 = False
61
  torch.backends.cuda.matmul.allow_bf16_reduced_precision_reduction = False
@@ -194,29 +197,29 @@ def load_and_prepare_model():
194
  pipe.text_encoder.eval()
195
  '''
196
 
197
- pipe.unet = pipe.unet.to(memory_format=torch.contiguous_format)
198
 
199
- #pipe.unet.to(memory_format=torch.channels_last)
200
  #pipe.enable_vae_tiling()
201
  #pipe.unet = torch.compile(pipe.unet, backend="hidet", dynamic=False, mode='max-autotune') #.to(device=device, dtype=torch.bfloat16)
202
  #pipe.unet = torch.compile(pipe.unet, backend="hidet", dynamic=False, mode='max-autotune-no-cudagraphs') #.to(device=device, dtype=torch.bfloat16)
203
  #pipe.unet = torch.compile(pipe.unet, backend="hidet", dynamic=False, options={'epilogue_fusion': True, 'shape_padding': True}) #.to(device=device, dtype=torch.bfloat16)
204
- pipe.unet = torch.compile(pipe.unet, dynamic=False)
205
  #pipe.unet = torch.compile(pipe.unet, backend="hidet", dynamic=False, options={"search_space": 0})
206
  #pipe.unet = torch.compile(pipe.unet, backend="torch_tensorrt", dynamic=False, options={"precision": torch.bfloat16,"optimization_level": 4,})
207
  pipe.to(device=device, dtype=torch.bfloat16)
208
 
209
  return pipe
210
 
211
- hidet.option.parallel_build(False)
212
- hidet.option.parallel_tune(2,2.0)
213
  #torch._dynamo.config.suppress_errors = True
214
- torch._dynamo.disallow_in_graph(diffusers.models.attention.BasicTransformerBlock)
215
 
216
  # more search
217
  #hidet.torch.dynamo_config.search_space(0)
218
  #hidet.torch.dynamo_config.dump_graph_ir("./local_graph")
219
- hidet.option.cache_dir("local_cache")
220
  # automatically transform the model to use float16 data type
221
  #hidet.torch.dynamo_config.use_fp16(True)
222
  # use float16 data type as the accumulate data type in operators with reduction
@@ -229,7 +232,7 @@ hidet.option.cache_dir("local_cache")
229
 
230
  pipe = load_and_prepare_model()
231
 
232
- MAX_SEED = np.iinfo(np.int32).max
233
 
234
  neg_prompt_2 = " 'non-photorealistic':1.5, 'unrealistic skin','unattractive face':1.3, 'low quality':1.1, ('dull color scheme', 'dull colors', 'digital noise':1.2),'amateurish', 'poorly drawn face':1.3, 'poorly drawn', 'distorted face', 'low resolution', 'simplistic' "
235
 
 
7
  import spaces
8
  import os
9
 
10
+ #import subprocess
11
+ #subprocess.run(['sh', './conda.sh'])
12
 
13
+ #import sys
14
+ #conda_prefix = os.path.expanduser("~/miniconda3")
15
+ #conda_bin = os.path.join(conda_prefix, "bin")
16
 
17
  # Add Conda's bin directory to your PATH
18
+ #os.environ["PATH"] = conda_bin + os.pathsep + os.environ["PATH"]
19
 
20
  # Activate the base environment (adjust if needed)
21
+ #os.system(f'{conda_bin}/conda init --all')
22
+ #os.system(f'{conda_bin}/conda activate base')
23
+
24
+
25
  #os.system(f'{conda_bin}/conda install nvidia/label/cudnn-9.3.0::cudnn')
26
  #os.system(f'{conda_bin}/conda install nvidia/label/cuda-12.4.0::cuda-libraries')
27
  #os.system(f'{conda_bin}/conda install nvidia/label/cuda-12.4.0::cuda-libraries-dev')
28
  #os.system(f'{conda_bin}/conda install nvidia/label/cuda-12.4.0::cuda-cudart')
29
  #os.system(f'{conda_bin}/conda install nvidia/label/cuda-12.4.0::cuda-cudart-dev')
30
  #os.system(f'{conda_bin}/conda install nvidia/label/cuda-12.4.0::cuda-nvcc')
31
+
32
+ #os.system(f'{conda_bin}/conda install nvidia/label/cuda-12.4.0::cuda-toolkit')
33
 
34
  #subprocess.run(['pip', 'install', 'git+https://github.com/hidet-org/hidet.git'])
35
  #subprocess.run(['pip', 'install', 'git+https://github.com/ford442/hidet.git@thread'])
 
38
  #os.system(f'{conda_bin}/conda install rcdr_py37::tensorrt')
39
  #subprocess.run(['sh', './hidet.sh'])
40
  #subprocess.run(['sh', './modelopt.sh'])
41
+ #import hidet
42
  #print(dir(hidet))
43
  #import torch_tensorrt
44
 
 
57
  import cyper
58
  from image_gen_aux import UpscaleWithModel
59
  import torch
60
+ #import torch._dynamo
61
+ #torch._dynamo.list_backends()
62
 
63
  torch.backends.cuda.matmul.allow_tf32 = False
64
  torch.backends.cuda.matmul.allow_bf16_reduced_precision_reduction = False
 
197
  pipe.text_encoder.eval()
198
  '''
199
 
200
+ #pipe.unet = pipe.unet.to(memory_format=torch.contiguous_format)
201
 
202
+ pipe.unet.to(memory_format=torch.channels_last)
203
  #pipe.enable_vae_tiling()
204
  #pipe.unet = torch.compile(pipe.unet, backend="hidet", dynamic=False, mode='max-autotune') #.to(device=device, dtype=torch.bfloat16)
205
  #pipe.unet = torch.compile(pipe.unet, backend="hidet", dynamic=False, mode='max-autotune-no-cudagraphs') #.to(device=device, dtype=torch.bfloat16)
206
  #pipe.unet = torch.compile(pipe.unet, backend="hidet", dynamic=False, options={'epilogue_fusion': True, 'shape_padding': True}) #.to(device=device, dtype=torch.bfloat16)
207
+ #pipe.unet = torch.compile(pipe.unet, dynamic=False)
208
  #pipe.unet = torch.compile(pipe.unet, backend="hidet", dynamic=False, options={"search_space": 0})
209
  #pipe.unet = torch.compile(pipe.unet, backend="torch_tensorrt", dynamic=False, options={"precision": torch.bfloat16,"optimization_level": 4,})
210
  pipe.to(device=device, dtype=torch.bfloat16)
211
 
212
  return pipe
213
 
214
+ #hidet.option.parallel_build(False)
215
+ #hidet.option.parallel_tune(2,2.0)
216
  #torch._dynamo.config.suppress_errors = True
217
+ #torch._dynamo.disallow_in_graph(diffusers.models.attention.BasicTransformerBlock)
218
 
219
  # more search
220
  #hidet.torch.dynamo_config.search_space(0)
221
  #hidet.torch.dynamo_config.dump_graph_ir("./local_graph")
222
+ # hidet.option.cache_dir("local_cache")
223
  # automatically transform the model to use float16 data type
224
  #hidet.torch.dynamo_config.use_fp16(True)
225
  # use float16 data type as the accumulate data type in operators with reduction
 
232
 
233
  pipe = load_and_prepare_model()
234
 
235
+ MAX_SEED = np.iinfo(np.int64).max
236
 
237
  neg_prompt_2 = " 'non-photorealistic':1.5, 'unrealistic skin','unattractive face':1.3, 'low quality':1.1, ('dull color scheme', 'dull colors', 'digital noise':1.2),'amateurish', 'poorly drawn face':1.3, 'poorly drawn', 'distorted face', 'low resolution', 'simplistic' "
238