Spaces:
qatiba
/
Runtime error

jamalsenouci commited on
Commit
bb0cc49
β€’
1 Parent(s): c6919c4

Upload folder using huggingface_hub

Browse files
notebooks/.ipynb_checkpoints/use_small_models_on_cpu-checkpoint.ipynb ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "6a682b61",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Benchmarking small models on CPU\n",
9
+ " - We can enable small models with the `SUNO_USE_SMALL_MODELS` environment variable"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": 1,
15
+ "id": "9500dd93",
16
+ "metadata": {},
17
+ "outputs": [],
18
+ "source": [
19
+ "import os\n",
20
+ "\n",
21
+ "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"\"\n",
22
+ "os.environ[\"SUNO_USE_SMALL_MODELS\"] = \"1\"\n",
23
+ "\n",
24
+ "from IPython.display import Audio\n",
25
+ "import numpy as np\n",
26
+ "\n",
27
+ "from bark import generate_audio, preload_models, SAMPLE_RATE\n",
28
+ "\n",
29
+ "import time"
30
+ ]
31
+ },
32
+ {
33
+ "cell_type": "code",
34
+ "execution_count": 2,
35
+ "id": "4e3454b6",
36
+ "metadata": {},
37
+ "outputs": [
38
+ {
39
+ "name": "stderr",
40
+ "output_type": "stream",
41
+ "text": [
42
+ "No GPU being used. Careful, inference might be very slow!\n"
43
+ ]
44
+ },
45
+ {
46
+ "name": "stdout",
47
+ "output_type": "stream",
48
+ "text": [
49
+ "CPU times: user 5.52 s, sys: 2.34 s, total: 7.86 s\n",
50
+ "Wall time: 4.33 s\n"
51
+ ]
52
+ }
53
+ ],
54
+ "source": [
55
+ "%%time\n",
56
+ "preload_models()"
57
+ ]
58
+ },
59
+ {
60
+ "cell_type": "code",
61
+ "execution_count": 3,
62
+ "id": "f6024e5f",
63
+ "metadata": {},
64
+ "outputs": [
65
+ {
66
+ "name": "stderr",
67
+ "output_type": "stream",
68
+ "text": [
69
+ "100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 100/100 [00:10<00:00, 9.89it/s]\n",
70
+ "100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15/15 [00:43<00:00, 2.90s/it]\n"
71
+ ]
72
+ },
73
+ {
74
+ "name": "stdout",
75
+ "output_type": "stream",
76
+ "text": [
77
+ "took 62s to generate 6s of audio\n"
78
+ ]
79
+ }
80
+ ],
81
+ "source": [
82
+ "t0 = time.time()\n",
83
+ "text = \"In the light of the moon, a little egg lay on a leaf\"\n",
84
+ "audio_array = generate_audio(text)\n",
85
+ "generation_duration_s = time.time() - t0\n",
86
+ "audio_duration_s = audio_array.shape[0] / SAMPLE_RATE\n",
87
+ "\n",
88
+ "print(f\"took {generation_duration_s:.0f}s to generate {audio_duration_s:.0f}s of audio\")"
89
+ ]
90
+ },
91
+ {
92
+ "cell_type": "code",
93
+ "execution_count": 4,
94
+ "id": "2dcce86c",
95
+ "metadata": {},
96
+ "outputs": [
97
+ {
98
+ "data": {
99
+ "text/plain": [
100
+ "10"
101
+ ]
102
+ },
103
+ "execution_count": 4,
104
+ "metadata": {},
105
+ "output_type": "execute_result"
106
+ }
107
+ ],
108
+ "source": [
109
+ "os.cpu_count()"
110
+ ]
111
+ },
112
+ {
113
+ "cell_type": "code",
114
+ "execution_count": null,
115
+ "id": "3046eddb",
116
+ "metadata": {},
117
+ "outputs": [],
118
+ "source": []
119
+ }
120
+ ],
121
+ "metadata": {
122
+ "kernelspec": {
123
+ "display_name": "Python 3 (ipykernel)",
124
+ "language": "python",
125
+ "name": "python3"
126
+ },
127
+ "language_info": {
128
+ "codemirror_mode": {
129
+ "name": "ipython",
130
+ "version": 3
131
+ },
132
+ "file_extension": ".py",
133
+ "mimetype": "text/x-python",
134
+ "name": "python",
135
+ "nbconvert_exporter": "python",
136
+ "pygments_lexer": "ipython3",
137
+ "version": "3.9.16"
138
+ }
139
+ },
140
+ "nbformat": 4,
141
+ "nbformat_minor": 5
142
+ }
requirements.txt CHANGED
@@ -1,3 +1,4 @@
 
1
  transformers
2
  diffusers
3
  ffmpeg
 
1
+ devtools
2
  transformers
3
  diffusers
4
  ffmpeg