Spaces:
Sleeping
Sleeping
File size: 1,386 Bytes
af8ab52 d9f3d2e da248b3 2da83a5 d9f3d2e a569343 d9f3d2e a569343 d9f3d2e af8ab52 d9f3d2e af8ab52 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
from transformers import pipeline
def main():
messages = [
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
{"role": "user", "content": "Who are you?"},
]
chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.3")
r=chatbot(messages)
print(r)
"""
import os
import time
from datetime import timedelta
import numpy as np
from threading import Thread
import streamlit as st
def cpu_benchmark(cores, iterations=100000000):
start = time.perf_counter()
num_threads = iterations // cores
threads = []
for i in range(cores):
t = Thread(target=np.random.randn, args=(num_threads,))
threads.append(t)
t.start()
for t in threads:
t.join()
end = time.perf_counter()
elapsed = end - start
return elapsed / iterations, elapsed
def main():
st.title("CPU Benchmark")
st.write("Select the number of cores to use for the benchmark.")
cores = int(st.slider("Number of Cores", 1, os.cpu_count(), step=1))
submit_button = st.button("Run Benchmark")
if submit_button:
elapsed_time, total_time = cpu_benchmark(cores)
result = f"Elapsed Time per Iteration: {elapsed_time:.6f} seconds\nTotal Time: {total_time:.6f} seconds"
st.success(result)
"""
if __name__ == "__main__":
main()
|