1
4

More than 1 year has passed since last update.

WSLでlocal版の Open Interpreter を動かす

Posted at

Open InterpreterをWSLで動かしてみたときのメモ。

Open Interpreter のインストール

まず、新しい環境をpyenvとvenvで構築する。
Anacondaとか使う場合は適宜読み替える。既存の環境が変わっても気にしない場合はスキップする。
ただし、pythonのバージョンは3.10以上である必要がある。

> mkdir interpreter
> cd interpreter
> pyenv install 3.11.3
> pyenv global 3.11.3
> python -m venv ./venv
> . ./venv/bin/activate

open interpreterをインストール。

> pip install open-interpreter 

Code Llamaを試してみたかったので、ローカルモードで実行する。
モデルをダウンロード後、llama-cpp-pythonのインストールでエラーになる。
(なお、環境は Windows 10 上の Ubuntu 22.04.3 LTS)

> interpreter --local
()
  ERROR: Failed building wheel for llama-cpp-python
Failed to build llama-cpp-python
ERROR: Could not build wheels for llama-cpp-python, which is required to install pyproject.toml-based projects

このあたりを参考にllama-cpp-pythonをインストール。

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 60 --slave /usr/bin/g++ g++ /usr/bin/g++-11
pip install --upgrade pip
pip install --upgrade setuptools wheel
sudo apt-get install build-essential
set "CMAKE_ARGS=-DLLAMA_OPENBLAS=on"
set "FORCE_CMAKE=1"
pip install llama-cpp-python --no-cache-dir

再度実行すると成功し、プロンプトが表示される。

> interpreter --local
()
▌ Model set to TheBloke/CodeLlama-13B-Instruct-GGUF

Open Interpreter will require approval before running code. Use interpreter -y to bypass this.

Press CTRL-C to exit.

>

ChatGPT-4との比較

GPUのメモリの関係で動かせる限界の13B Medium Sizeしか動かせなかったが、
Code Llama と、ChatGPT-4 で出力を比べてみた。

とりあえず100番目の素数を聞いてみた。

Code Llama 13B Medium

方法が分からなかったらしい。

> tell me the 100th prime number.
  import math
  print(math.prime(100))
  Would you like to run this code? (y/n)

  y
  import math
  print(math.prime(100))
  File "<stdin>", line 6, in <module>
  AttributeError: module 'math' has no attribute 'prime'


  I would like to know how to find the 100th prime number.

>

ChatGPT-4

当然だが、Code Llamaより賢い。

> tell me the 100th prime number.

  Sure, I can do that. Here is the plan:

   1 Write a function to check if a number is prime.
   2 Iterate from 2 upwards, checking each number to see if it's prime.
   3 Stop when we have found the 100th prime number.

  Let's start with the first step, writing a function to check if a number is prime.
  def is_prime(n):
      if n <= 1:
          return False
      if n == 2:
          return True
      if n % 2 == 0:
          return False
      i = 3
      while i * i <= n:
          if n % i == 0:
              return False
          i += 2
      return True

  # Test the function with a known prime number
  print(is_prime(13))
  Would you like to run this code? (y/n)

  y
  def is_prime(n):
      if n <= 1:
          return False
      if n == 2:
          return True
      if n % 2 == 0:
          return False
      i = 3
      while i * i <= n:
          if n % i == 0:
              return False
          i += 2
      return True

  # Test the function with a known prime number
  print(is_prime(13))
  True

  The function to check if a number is prime is working correctly, as it correctly identified 13 as a prime number.

  Now, let's move on to the next step of the plan: iterating from 2 upwards, checking each number to see if it's
  prime, and stopping when we have found the 100th prime number.
  def nth_prime(n):
      count = 0
      num = 2
      while True:
          if is_prime(num):
              count += 1
              if count == n:
                  return num
          num += 1

  # Find the 100th prime number
  print(nth_prime(100))
  Would you like to run this code? (y/n)

  y
  def nth_prime(n):
      count = 0
      num = 2
      while True:
          if is_prime(num):
              count += 1
              if count == n:
                  return num
          num += 1

  # Find the 100th prime number
  print(nth_prime(100))
  541

  The 100th prime number is 541.
1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4