dottxt-ai/outlines

Outlines doesn't install on Collab because Rust isn't available to compile outlines core

Closed this issue · 15 comments

Describe the issue as clearly as possible:

Outlines doesn't install successfully via

!pip install outlines

on Google Colab.

Steps/code to reproduce the bug:

!pip install outlines

Expected result:

Successful installation of Outlines in Google Colab.

Error message:

********************************************************************************
          ############################
          # Package would be ignored #
          ############################
          Python recognizes 'outlines_core.integrations' as an importable package[^1],
          but it is absent from setuptools' `packages` configuration.

          This leads to an ambiguous overall configuration. If you want to distribute this
          package, please make sure that 'outlines_core.integrations' is explicitly added
          to the `packages` configuration field.

          Alternatively, you can also rely on setuptools' discovery methods
          (for example by using `find_namespace_packages(...)`/`find_namespace:`
          instead of `find_packages(...)`/`find:`).

          You can read more about "package discovery" on setuptools documentation page:

          - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

          If you don't want 'outlines_core.integrations' to be distributed and are
          already explicitly excluding 'outlines_core.integrations' via
          `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
          you can try to use `exclude_package_data`, or `include-package-data=False` in
          combination with a more fine grained `package-data` configuration.

          You can read more about "package data files" on setuptools documentation page:

          - https://setuptools.pypa.io/en/latest/userguide/datafiles.html


          [^1]: For Python, any directory (with suitable naming) can be imported,
                even if it does not contain any `.py` files.
                On the other hand, currently there is no concept of package data
                directory, all directories are treated like packages.
          ********************************************************************************

  !!
    check.warn(importable)
  /tmp/pip-build-env-aoesym4_/overlay/local/lib/python3.10/dist-packages/setuptools/command/build_py.py:218: _Warning: Package 'outlines_core.models' is absent from the `packages` configuration.
  !!

          ********************************************************************************
          ############################
          # Package would be ignored #
          ############################
          Python recognizes 'outlines_core.models' as an importable package[^1],
          but it is absent from setuptools' `packages` configuration.

          This leads to an ambiguous overall configuration. If you want to distribute this
          package, please make sure that 'outlines_core.models' is explicitly added
          to the `packages` configuration field.

          Alternatively, you can also rely on setuptools' discovery methods
          (for example by using `find_namespace_packages(...)`/`find_namespace:`
          instead of `find_packages(...)`/`find:`).

          You can read more about "package discovery" on setuptools documentation page:

          - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

          If you don't want 'outlines_core.models' to be distributed and are
          already explicitly excluding 'outlines_core.models' via
          `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
          you can try to use `exclude_package_data`, or `include-package-data=False` in
          combination with a more fine grained `package-data` configuration.

          You can read more about "package data files" on setuptools documentation page:

          - https://setuptools.pypa.io/en/latest/userguide/datafiles.html


          [^1]: For Python, any directory (with suitable naming) can be imported,
                even if it does not contain any `.py` files.
                On the other hand, currently there is no concept of package data
                directory, all directories are treated like packages.
          ********************************************************************************

  !!
    check.warn(importable)
  copying python/outlines_core/py.typed -> build/lib.linux-x86_64-cpython-310/outlines_core
  creating build/lib.linux-x86_64-cpython-310/outlines_core/fsm
  copying python/outlines_core/fsm/__init__.py -> build/lib.linux-x86_64-cpython-310/outlines_core/fsm
  copying python/outlines_core/fsm/fsm.py -> build/lib.linux-x86_64-cpython-310/outlines_core/fsm
  copying python/outlines_core/fsm/guide.py -> build/lib.linux-x86_64-cpython-310/outlines_core/fsm
  copying python/outlines_core/fsm/json_schema.py -> build/lib.linux-x86_64-cpython-310/outlines_core/fsm
  copying python/outlines_core/fsm/regex.py -> build/lib.linux-x86_64-cpython-310/outlines_core/fsm
  copying python/outlines_core/fsm/types.py -> build/lib.linux-x86_64-cpython-310/outlines_core/fsm
  creating build/lib.linux-x86_64-cpython-310/outlines_core/integrations
  copying python/outlines_core/integrations/utils.py -> build/lib.linux-x86_64-cpython-310/outlines_core/integrations
  creating build/lib.linux-x86_64-cpython-310/outlines_core/models
  copying python/outlines_core/models/__init__.py -> build/lib.linux-x86_64-cpython-310/outlines_core/models
  copying python/outlines_core/models/tokenizer.py -> build/lib.linux-x86_64-cpython-310/outlines_core/models
  copying python/outlines_core/models/transformers.py -> build/lib.linux-x86_64-cpython-310/outlines_core/models
  running build_ext
  running build_rust
  error: can't find Rust compiler

  If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.

  To update pip, run:

      pip install --upgrade pip

  and then retry package installation.

  If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.
  error: subprocess-exited-with-error
  
  × Building wheel for outlines-core (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /usr/bin/python3 /usr/local/lib/python3.10/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmphx3fhi6x
  cwd: /tmp/pip-install-szpvw5jq/outlines-core_7cc4c742fcc74987987bc589fe954a42
  Building wheel for outlines-core (pyproject.toml) ... error
  ERROR: Failed building wheel for outlines-core
Failed to build outlines-core
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (outlines-core)

Outlines/Python version information:

Version information

``` (command output here) ```

Context for the issue:

The issue stems from a Rust compiler not being available on a standard Colab instance. It can be resolved by installing the Rust compiler, but this might not be an ideal user experience for people just starting with Outlines.

In the meantime, for anyone trying to use Outlines in a Colab instance:

import os
!curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
!source $HOME/.cargo/env
os.environ['PATH'] += ':/root/.cargo/bin'
!echo $PATH
!pip install outlines 

Should install correctly.

same on a fresh Linux VM

Thank you for opening an issue! We'll solve this on the outlines-core side and cut a new release.

same error

downgrade to outlines==0.0.46 is work for me.

same error

We're working on this as I am typing this. Expect an update soon!

downgrade to outlines==0.0.46 is work for me.

it worked for me, thanks!

lapp0 commented

Can you please try pip install git+https://github.com/lapp0/outlines@add-fsm-union-pin-core and report back whether it works? This is the branch of a PR in progress which fixes the rust installation issue.

Can you please try pip install git+https://github.com/lapp0/outlines@add-fsm-union-pin-core and report back whether it works? This is the branch of a PR in progress which fixes the rust installation issue.

@lapp0 seems to work now. I only tested install, import and demo code i.e.

!pip install git+https://github.com/lapp0/outlines@add-fsm-union-pin-core
!pip install transformers --upgrade

import outlines

model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")

prompt = """You are a sentiment-labelling assistant.
Is the following review positive or negative?

Review: This restaurant is just awesome!
"""

generator = outlines.generate.choice(model, ["Positive", "Negative"])
answer = generator(prompt)

but all seemed to work well.

lapp0 commented

Thanks so much for helping me test it! I expect a new release soon with the mentioned branch included.

In the meantime, for anyone trying to use Outlines in a Colab instance:

import os
!curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
!source $HOME/.cargo/env
os.environ['PATH'] += ':/root/.cargo/bin'
!echo $PATH
!pip install outlines 

Should install correctly.

It works for me!! thx ! @davanstrien

Hi - I'm still running into this issue. I tried both of these with the same result:

pip install git+https://github.com/lapp0/outlines@add-fsm-union-pin-core and
pip install outlines

Any recommendations?

In the meantime, for anyone trying to use Outlines in a Colab instance:

import os
!curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
!source $HOME/.cargo/env
os.environ['PATH'] += ':/root/.cargo/bin'
!echo $PATH
!pip install outlines 

Should install correctly.

It works!
This is my dockerfile

RUN apt-get update && \
    apt-get install -y curl && \
    rm -rf /var/lib/apt/lists/*

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
    . "$HOME/.cargo/env" && \
    echo 'export PATH=$PATH:$HOME/.cargo/bin' >> ~/.bashrc && \
    /bin/bash -c "source ~/.bashrc"

ENV PATH="/root/.cargo/bin:${PATH}"

RUN pip install --upgrade pip


RUN pip install outlines==0.1.1
rlouf commented

pip install outlines==0.1,1 should work. If not please paste the error and the system you are running (Windows, Mac, Linux) and the OS version.