Domz1313 commited on
Commit
707ff98
·
1 Parent(s): 0d10217

added torch

Browse files
Files changed (3) hide show
  1. app.py +19 -7
  2. requirements.txt +5 -1
  3. softwaresim-diagram.yaml +443 -0
app.py CHANGED
@@ -1,14 +1,26 @@
1
  import gradio as gr
 
 
2
  import spaces
3
  import torch
4
 
5
- zero = torch.Tensor([0]).cuda()
6
- print(zero.device)
7
 
8
  @spaces.GPU
9
- def greet(n):
10
- print(zero.device)
11
- return f"Hello {zero + n} Tensor"
 
 
12
 
13
- demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
14
- demo.launch()
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import huggingface_hub
3
+ import os
4
  import spaces
5
  import torch
6
 
7
+ from transformers import AutoTokenizer, AutoModelForCausalLM
 
8
 
9
  @spaces.GPU
10
+ def sentience_check():
11
+ huggingface_hub.login(token=os.environ["HUGGINGFACE_TOKEN"])
12
+ device = torch.device("cuda")
13
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-it")
14
+ model = AutoModelForCausalLM.from_pretrained("google/gemma-2-2b-it").to(device)
15
 
16
+ inputs = tokenizer("Are you sentient?", return_tensors="pt").to(device)
17
+
18
+ with torch.no_grad():
19
+ outputs = model.generate(
20
+ **inputs, max_new_tokens=128, pad_token_id = tokenizer.eos_token_id
21
+ )
22
+
23
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
24
+
25
+ demo = gr.Interface(fn=sentience_check, inputs=None, outputs=gr.Text())
26
+ demo.launch()
requirements.txt CHANGED
@@ -1,4 +1,8 @@
1
  gradio
2
  transformers
3
  torch
4
- torchvision
 
 
 
 
 
1
  gradio
2
  transformers
3
  torch
4
+ torchvision
5
+ huggingface_hub==0.24.5
6
+ transformers==4.43.4
7
+ accelerate
8
+ --extra-index-url https://download.pytorch.org/whl/cu118
softwaresim-diagram.yaml ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mouseWheel:
2
+ _isScalar: false
3
+ closed: false
4
+ isStopped: false
5
+ hasError: false
6
+ thrownError: null
7
+ __isAsync: false
8
+ elementDraw:
9
+ _isScalar: false
10
+ closed: false
11
+ isStopped: false
12
+ hasError: false
13
+ thrownError: null
14
+ __isAsync: false
15
+ snapSettings:
16
+ constraints: 16
17
+ serializationSettings:
18
+ preventDefaults: true
19
+ contextMenuSettings:
20
+ show: true
21
+ items:
22
+ - text: Edit
23
+ id: edit
24
+ target: .e-elementcontent
25
+ iconCss: fa fa-cogs
26
+ - text: Callout To
27
+ id: callout
28
+ target: .e-elementcontent
29
+ iconCss: fa fa-crosshairs
30
+ - text: Increase font size ↑
31
+ id: increaseFontSize
32
+ target: .e-elementcontent
33
+ iconCss: fa fa-font
34
+ - text: Decrease font size ↓
35
+ id: decreaseFontSize
36
+ target: .e-elementcontent
37
+ iconCss: fa fa-font
38
+ - text: Fill
39
+ id: fill
40
+ target: .e-elementcontent
41
+ iconCss: fa fa-tint
42
+ - text: Highlight
43
+ id: highlight
44
+ target: .e-elementcontent
45
+ iconCss: fa fa-lightbulb-o
46
+ - text: Collapse to square
47
+ id: collapseToSquare
48
+ target: .e-elementcontent
49
+ iconCss: fa fa-compress
50
+ - text: Collapse to named square
51
+ id: collapseToNamedSquare
52
+ target: .e-elementcontent
53
+ iconCss: fa fa-compress
54
+ - text: Collapse to circle
55
+ id: collapseToCircle
56
+ target: .e-elementcontent
57
+ iconCss: fa fa-compress
58
+ - text: Expand
59
+ id: expand
60
+ target: .e-elementcontent
61
+ iconCss: fa fa-expand
62
+ - text: Bring to front
63
+ id: front
64
+ target: .e-elementcontent
65
+ iconCss: fa fa-angle-double-up
66
+ - text: Bring forward
67
+ id: forward
68
+ target: .e-elementcontent
69
+ iconCss: fa fa-angle-up
70
+ - text: Send backward
71
+ id: backward
72
+ target: .e-elementcontent
73
+ iconCss: fa fa-angle-down
74
+ - text: Send to back
75
+ id: back
76
+ target: .e-elementcontent
77
+ iconCss: fa fa-angle-double-down
78
+ - text: Remove
79
+ id: remove
80
+ target: .e-elementcontent
81
+ iconCss: fa fa-times
82
+ showCustomMenuOnly: true
83
+ tool: 5
84
+ scrollSettings:
85
+ scrollLimit: Infinity
86
+ viewPortWidth: 1179.9000244140625
87
+ viewPortHeight: 762
88
+ addInfo:
89
+ currencyText: USD ($)
90
+ currencySymbol: $
91
+ selectedViewType: 0
92
+ height: 762
93
+ nodes:
94
+ - shape:
95
+ type: HTML
96
+ content: '<div class="c-html" style="background-color: #9E630B;"><div
97
+ class="c-container"><div class="c-image-primary"
98
+ style="background-image:
99
+ url(https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face_Black_87_l3pdsp.png);"></div><div
100
+ class="c-image-original" style="background-image:
101
+ url(https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face_rssxni.png);"></div><div
102
+ class="c-text"><div class="c-title">Hugging Face Spaces</div><div
103
+ class="c-short-description">Spaces allow you to build and share ML apps
104
+ easily</div><div class="c-bottom"><div class="c-hr p-mb-1"></div><div
105
+ class="c-title-bottom">Hugging Face</div></div></div></div></div>'
106
+ id: Hugging FaceXW5CN
107
+ addInfo:
108
+ functionView:
109
+ leadTime: 0
110
+ leadTimeSeconds: 0
111
+ processTime: 0
112
+ processTimeSeconds: 0
113
+ completeAndAccuratePerc: 0
114
+ activityRatio: 0
115
+ viewType: metrics
116
+ name: Hugging Face
117
+ shortDescription: Spaces allow you to build and share ML apps easily
118
+ economicView:
119
+ cpus: 0
120
+ memory: 0
121
+ storage: 0
122
+ networking: 0
123
+ accelerators: 0
124
+ other: 0
125
+ unknown: false
126
+ viewType: total
127
+ name: Hugging Face
128
+ status: N/A
129
+ size: sm
130
+ nodeType: html
131
+ title: Hugging Face
132
+ editableName: Hugging Face Spaces
133
+ type: component
134
+ id: ""
135
+ dynamicsViewSettings:
136
+ - name: Model Repository
137
+ type: Storage
138
+ portsIn:
139
+ put: models
140
+ get: fetch
141
+ portsOut:
142
+ stored: models
143
+ dynamicsViews:
144
+ - type: Storage
145
+ status: Idle
146
+ name: Model Repository
147
+ name: Hugging Face
148
+ category: 2
149
+ imgUrl: https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face_rssxni.png
150
+ imgPrimaryUrl: https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face__044448_dhzej2.png
151
+ imgBlackUrl: https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face_Black_87_l3pdsp.png
152
+ color: "#9E630B"
153
+ controlText: Hugging Face
154
+ selectedDynamicsView: 0
155
+ latitude: null
156
+ longitude: null
157
+ width: 300
158
+ height: 100
159
+ offsetX: 447
160
+ offsetY: 229
161
+ zIndex: 0
162
+ outEdges:
163
+ - Orthogonal ConnectorIwleg
164
+ - shape:
165
+ type: HTML
166
+ content: '<div class="c-html" style="background-color: #5A821F; border-radius:
167
+ 10px"><div class="c-container"><div class="c-image-primary"
168
+ style="background-image:
169
+ url(https://res.cloudinary.com/dwohyn92h/image/upload/v1705563398/sds_logos/Nvidia_Black_87_mhcpj8.png);"></div><div
170
+ class="c-image-original" style="background-image:
171
+ url(https://res.cloudinary.com/dwohyn92h/image/upload/v1705563398/sds_logos/Nvidia_a73jyo.png);
172
+ border-radius: 10px"></div></div><div class="c-undername"><div>Nvidia
173
+ A100s</div></div><hr class="c-underrule" style="background-color:
174
+ #5A821F"></div>'
175
+ id: Nvidiaf0JFI
176
+ addInfo:
177
+ functionView:
178
+ leadTime: 0
179
+ leadTimeSeconds: 0
180
+ processTime: 0
181
+ processTimeSeconds: 0
182
+ completeAndAccuratePerc: 0
183
+ activityRatio: 0
184
+ viewType: metrics
185
+ name: Nvidia
186
+ economicView:
187
+ cpus: 0
188
+ memory: 0
189
+ storage: 0
190
+ networking: 0
191
+ accelerators: 0
192
+ other: 0
193
+ unknown: false
194
+ viewType: total
195
+ name: Nvidia
196
+ status: N/A
197
+ size: sm
198
+ nodeType: html
199
+ title: Nvidia
200
+ editableName: Nvidia A100s
201
+ type: component
202
+ id: ""
203
+ dynamicsViewSettings:
204
+ - name: Processing Tool
205
+ type: Processor
206
+ portsIn:
207
+ job: input
208
+ portsOut:
209
+ job: output
210
+ serviceTime:
211
+ exp:
212
+ lambda: AverageProcessingTime
213
+ dynamicsViews:
214
+ - type: Processor
215
+ status: Idle
216
+ name: Processing Tool
217
+ AverageProcessingTime: 1
218
+ name: Nvidia
219
+ category: 0
220
+ imgUrl: https://res.cloudinary.com/dwohyn92h/image/upload/v1705563398/sds_logos/Nvidia_a73jyo.png
221
+ imgPrimaryUrl: https://res.cloudinary.com/dwohyn92h/image/upload/v1705563398/sds_logos/Nvidia__044448_mn6spy.png
222
+ imgBlackUrl: https://res.cloudinary.com/dwohyn92h/image/upload/v1705563398/sds_logos/Nvidia_Black_87_mhcpj8.png
223
+ color: "#5A821F"
224
+ controlText: Nvidia
225
+ selectedDynamicsView: 0
226
+ latitude: null
227
+ longitude: null
228
+ collapsedToSquare: false
229
+ collapsedToNamedSquare: true
230
+ collapsedToCircle: false
231
+ width: 135.00000000000006
232
+ height: 124
233
+ offsetX: 603.5
234
+ offsetY: 510
235
+ zIndex: 1
236
+ inEdges:
237
+ - Dashed Straight Nondirectional ConnectorERs76
238
+ - shape:
239
+ type: HTML
240
+ content: '<div class="c-html" style="background-color: #9E630B;"><div
241
+ class="c-container"><div class="c-image-primary"
242
+ style="background-image:
243
+ url(https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face_Black_87_l3pdsp.png);"></div><div
244
+ class="c-image-original" style="background-image:
245
+ url(https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face_rssxni.png);"></div><div
246
+ class="c-text"><div class="c-title">Hugging Face Spaces</div><div
247
+ class="c-short-description">Spaces allow you to build and share ML apps
248
+ easily</div><div class="c-bottom"><div class="c-hr p-mb-1"></div><div
249
+ class="c-title-bottom">Hugging Face</div></div></div></div></div>'
250
+ id: Hugging FaceXW5CNFu2Tb
251
+ addInfo:
252
+ functionView:
253
+ leadTime: 0
254
+ leadTimeSeconds: 0
255
+ processTime: 0
256
+ processTimeSeconds: 0
257
+ completeAndAccuratePerc: 0
258
+ activityRatio: 0
259
+ viewType: metrics
260
+ name: Hugging Face
261
+ shortDescription: Spaces allow you to build and share ML apps easily
262
+ economicView:
263
+ cpus: 0
264
+ memory: 0
265
+ storage: 0
266
+ networking: 0
267
+ accelerators: 0
268
+ other: 0
269
+ unknown: false
270
+ viewType: total
271
+ name: Hugging Face
272
+ status: N/A
273
+ size: sm
274
+ nodeType: html
275
+ title: Hugging Face
276
+ editableName: Hugging Face Spaces
277
+ type: component
278
+ id: ""
279
+ dynamicsViewSettings:
280
+ - name: Model Repository
281
+ type: Storage
282
+ portsIn:
283
+ put: models
284
+ get: fetch
285
+ portsOut:
286
+ stored: models
287
+ dynamicsViews:
288
+ - type: Storage
289
+ status: Idle
290
+ name: Model Repository
291
+ name: Hugging Face
292
+ category: 2
293
+ imgUrl: https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face_rssxni.png
294
+ imgPrimaryUrl: https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face__044448_dhzej2.png
295
+ imgBlackUrl: https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face_Black_87_l3pdsp.png
296
+ color: "#9E630B"
297
+ controlText: Hugging Face
298
+ selectedDynamicsView: 0
299
+ latitude: null
300
+ longitude: null
301
+ width: 300
302
+ height: 100
303
+ offsetX: 762
304
+ offsetY: 229
305
+ zIndex: 3
306
+ outEdges:
307
+ - Orthogonal ConnectorOPJBU
308
+ - shape:
309
+ type: HTML
310
+ content: '<div class="c-html" style="background-color: #9E630B;"><div
311
+ class="c-container"><div class="c-image-primary"
312
+ style="background-image:
313
+ url(https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face_Black_87_l3pdsp.png);"></div><div
314
+ class="c-image-original" style="background-image:
315
+ url(https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face_rssxni.png);"></div><div
316
+ class="c-text"><div class="c-title">Hugging Face ZeroGPU</div><div
317
+ class="c-short-description">Dynamic GPU allocation system (using a free
318
+ pool of A100s for Pro users)</div><div class="c-bottom"><div class="c-hr
319
+ p-mb-1"></div><div class="c-title-bottom">Hugging
320
+ Face</div></div></div></div></div>'
321
+ id: Hugging FaceXW5CNURmc4
322
+ addInfo:
323
+ functionView:
324
+ leadTime: 0
325
+ leadTimeSeconds: 0
326
+ processTime: 0
327
+ processTimeSeconds: 0
328
+ completeAndAccuratePerc: 0
329
+ activityRatio: 0
330
+ viewType: metrics
331
+ name: Hugging Face
332
+ shortDescription: Dynamic GPU allocation system (using a free pool of A100s for
333
+ Pro users)
334
+ economicView:
335
+ cpus: 0
336
+ memory: 0
337
+ storage: 0
338
+ networking: 0
339
+ accelerators: 0
340
+ other: 0
341
+ unknown: false
342
+ viewType: total
343
+ name: Hugging Face
344
+ status: N/A
345
+ size: sm
346
+ nodeType: html
347
+ title: Hugging Face
348
+ editableName: Hugging Face ZeroGPU
349
+ type: component
350
+ id: ""
351
+ dynamicsViewSettings:
352
+ - name: Model Repository
353
+ type: Storage
354
+ portsIn:
355
+ put: models
356
+ get: fetch
357
+ portsOut:
358
+ stored: models
359
+ dynamicsViews:
360
+ - type: Storage
361
+ status: Idle
362
+ name: Model Repository
363
+ name: Hugging Face
364
+ category: 2
365
+ imgUrl: https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face_rssxni.png
366
+ imgPrimaryUrl: https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face__044448_dhzej2.png
367
+ imgBlackUrl: https://res.cloudinary.com/dwohyn92h/image/upload/v1682279834/Hugging_face_Black_87_l3pdsp.png
368
+ color: "#9E630B"
369
+ controlText: Hugging Face
370
+ selectedDynamicsView: 0
371
+ latitude: null
372
+ longitude: null
373
+ width: 300
374
+ height: 100
375
+ offsetX: 603.5
376
+ offsetY: 370
377
+ zIndex: 5
378
+ inEdges:
379
+ - Orthogonal ConnectorOPJBU
380
+ - Orthogonal ConnectorIwleg
381
+ outEdges:
382
+ - Dashed Straight Nondirectional ConnectorERs76
383
+ connectors:
384
+ - id: Orthogonal ConnectorIwleg
385
+ type: Orthogonal
386
+ targetDecorator:
387
+ shape: OpenArrow
388
+ style:
389
+ strokeWidth: 2
390
+ constraints: 470654
391
+ sourcePoint:
392
+ x: 447
393
+ y: 279
394
+ targetPoint:
395
+ x: 603.5
396
+ y: 320
397
+ sourceID: Hugging FaceXW5CN
398
+ targetID: Hugging FaceXW5CNURmc4
399
+ segments:
400
+ - type: Orthogonal
401
+ addInfo:
402
+ viewConnector: 0
403
+ zIndex: 2
404
+ - id: Orthogonal ConnectorOPJBU
405
+ type: Orthogonal
406
+ targetDecorator:
407
+ shape: OpenArrow
408
+ style:
409
+ strokeWidth: 2
410
+ constraints: 470654
411
+ sourcePoint:
412
+ x: 762
413
+ y: 279
414
+ targetPoint:
415
+ x: 603.5
416
+ y: 320
417
+ sourceID: Hugging FaceXW5CNFu2Tb
418
+ targetID: Hugging FaceXW5CNURmc4
419
+ segments:
420
+ - type: Orthogonal
421
+ addInfo:
422
+ viewConnector: 0
423
+ zIndex: 4
424
+ - id: Dashed Straight Nondirectional ConnectorERs76
425
+ targetDecorator:
426
+ shape: None
427
+ style:
428
+ strokeWidth: 2
429
+ strokeDashArray: 2 2
430
+ sourcePoint:
431
+ x: 603.5
432
+ y: 420
433
+ targetPoint:
434
+ x: 603.5
435
+ y: 448
436
+ sourceID: Hugging FaceXW5CNURmc4
437
+ targetID: Nvidiaf0JFI
438
+ addInfo:
439
+ viewConnector: 0
440
+ zIndex: 6
441
+ selectedItems:
442
+ width: 0
443
+ height: 0