Spaces:
Build error
Build error
Update app.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465model = "gemma2:27b"import osos.system("curl https://ollama.ai/install.sh | sh")import nest_asyncionest_asyncio.apply()import asyncio# Run Async Ollama# Taken from: https://stackoverflow.com/questions/77697302/how-to-run-ollama-in-google-colab# NB: You may need to set these depending and get cuda working depending which backend you are running.# Set environment variable for NVIDIA library# Set environment variables for CUDAos.environ['PATH'] += ':/usr/local/cuda/bin'# Set LD_LIBRARY_PATH to include both /usr/lib64-nvidia and CUDA lib directoriesos.environ['LD_LIBRARY_PATH'] = '/usr/lib64-nvidia:/usr/local/cuda/lib64'async def run_process(cmd):print('>>> starting', *cmd)process = await asyncio.create_subprocess_exec(*cmd,stdout=asyncio.subprocess.PIPE,stderr=asyncio.subprocess.PIPE)# define an async pipe functionasync def pipe(lines):async for line in lines:print(line.decode().strip())await asyncio.gather(pipe(process.stdout),pipe(process.stderr),)# call itawait asyncio.gather(pipe(process.stdout), pipe(process.stderr))import threadingasync def start_ollama_serve():await run_process(['ollama', 'serve'])def run_async_in_thread(loop, coro):asyncio.set_event_loop(loop)loop.run_until_complete(coro)loop.close()# Create a new event loop that will run in a new threadnew_loop = asyncio.new_event_loop()# Start ollama serve in a separate thread so the cell won't block executionthread = threading.Thread(target=run_async_in_thread, args=(new_loop, start_ollama_serve()))thread.start()# Load up modelos.system(f"ollama pull {model}")import copyimport gradio as gr12345678model = "gemma2:27b"import ollamaimport osollama_path="/usr/local/lib/python3.10/site-packages/ollama"os.system(f"{ollama_path} ollama pull {model}")import copyimport gradio as gr
app.py+4-61