Spaces:
Sleeping
Sleeping
| 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() | |