IlyasMoutawwakil HF staff commited on
Commit
4daeefd
1 Parent(s): 3aef4fb

refactor installs

Browse files
Files changed (2) hide show
  1. app.py +20 -11
  2. requirements.txt +1 -3
app.py CHANGED
@@ -1,4 +1,21 @@
1
- import torch
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import random
3
  import gradio as gr
4
  from optimum_benchmark.task_utils import (
@@ -15,13 +32,6 @@ from config_store import (
15
  get_pytorch_config,
16
  )
17
 
18
- cuda_available = torch.cuda.is_available()
19
-
20
- BACKENDS = ["pytorch", "onnxruntime", "openvino", "neural-compressor"]
21
- DEVICES = ["cpu", "cuda"] if cuda_available else ["cpu"]
22
- BENCHMARKS = ["inference", "training"]
23
-
24
-
25
  with gr.Blocks() as demo:
26
  # add image
27
  gr.Markdown(
@@ -33,11 +43,10 @@ with gr.Blocks() as demo:
33
  # explanation text
34
  gr.HTML(
35
  "<h3 style='text-align: center'>"
36
- "A zero code Gradio interface of <a href='https://github.com/huggingface/optimum-benchmark.git'>Optimum-Benchmark</a> :<br>"
37
  "</h3>"
38
  "<p style='text-align: center'>"
39
- "A unified multi-backend utility for benchmarking any model on the Hub including Transformers, Diffusers, PEFT and Timm models with "
40
- "Optimum's arsenal of optimizations & quantization schemes, for both inference & training, on multiple backends & hardware."
41
  "</p>"
42
  )
43
 
 
1
+ import os
2
+
3
+ nvidia_available = os.system("nvidia-smi") == 0
4
+ if nvidia_available:
5
+ os.system(
6
+ "pip install optimum-benchmark[onnxruntime-gpu,openvino,neural-compressor,diffusers,peft]@git+https://github.com/huggingface/optimum-benchmark.git"
7
+ )
8
+ DEVICES = ["cpu", "cuda"]
9
+ else:
10
+ os.system(
11
+ "pip install optimum-benchmark[onnxruntime,openvino,neural-compressor,diffusers,peft]@git+https://github.com/huggingface/optimum-benchmark.git"
12
+ )
13
+ DEVICES = ["cpu"]
14
+
15
+ BACKENDS = ["pytorch", "onnxruntime", "openvino", "neural-compressor"]
16
+ BENCHMARKS = ["inference", "training"]
17
+
18
+
19
  import random
20
  import gradio as gr
21
  from optimum_benchmark.task_utils import (
 
32
  get_pytorch_config,
33
  )
34
 
 
 
 
 
 
 
 
35
  with gr.Blocks() as demo:
36
  # add image
37
  gr.Markdown(
 
43
  # explanation text
44
  gr.HTML(
45
  "<h3 style='text-align: center'>"
46
+ "Zero code Gradio interface of <a href='https://github.com/huggingface/optimum-benchmark.git'>Optimum-Benchmark</a><br>"
47
  "</h3>"
48
  "<p style='text-align: center'>"
49
+ "Unlock "
 
50
  "</p>"
51
  )
52
 
requirements.txt CHANGED
@@ -1,3 +1 @@
1
- docker==6.1.3
2
- ansi2html==1.8.0
3
- optimum-benchmark[onnxruntime,openvino,neural-compressor,diffusers,peft]@git+https://github.com/huggingface/optimum-benchmark.git
 
1
+ ansi2html==1.8.0