Skip to content

Instantly share code, notes, and snippets.

@razhangwei
Last active August 15, 2024 02:51
Show Gist options
  • Save razhangwei/44c75c5397ad69487fb41bb97055a96f to your computer and use it in GitHub Desktop.
Save razhangwei/44c75c5397ad69487fb41bb97055a96f to your computer and use it in GitHub Desktop.
Google Colab tips #Colab
  • Top features
    • Generate full cell of code with gemini
    • Expain error with gemini and Google search.
  • Local connection
    • Option 1: jupyter notebook (simpler than docker, but with limited functionalities)
jupyter notebook \
    --NotebookApp.allow_origin='https://colab.research.google.com' \
    --port=8888 \
    --NotebookApp.port_retries=0
  • Settings

    • Editor, check
      • Enable code folding in the editor
      • Enable code wrapper in the editor
    • AI Assistance
      • Consented to use generative AI features
  • Free tiers:

Free Tiers

  • Limit seems reset every 12--24 hours.
    • Better to buy compute credits and be frugal in usage.
  • How to open termianl
    • execute:
!pip install colab-xterm
%load_ext colabxterm
  • in a new cell: %xterm

How to run run Ollama

  1. Install and launch ollama server
!pip install ollama
!curl -fsSL https://ollama.com/install.sh | sh
!nohup ollama serve &  # no hang up
!ollama pull llama3.1
  1. In code:
import ollama

response = ollama.generate(model='gemma:2b', prompt='What is a qubit?')
print(response['response'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment