From f99438e623891af122495af6cceefeb6991454a4 Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Sat, 7 Jan 2023 21:52:38 -0600 Subject: [PATCH] fix(docs): begin clarifying packages for each environment (#19) --- .gitlab-ci.yml | 2 +- README.md | 60 +++++++++++++++++++++++++++++++++----------- api/requirements.txt | 1 + 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7033e9fb..e27fab6e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -139,7 +139,7 @@ package-gui-oci-node-alpine: IMAGE_ARCH: node-alpine IMAGE_FILE: Containerfile.node.alpine -package-gui-oci-node-bullseye: +package-gui-oci-node-buster: extends: - .package-gui-oci variables: diff --git a/README.md b/README.md index 4126f620..2ec1dd66 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,10 @@ This is still an early project and the instructions are a little rough, but it w - [Install Git and Python](#install-git-and-python) - [Create a virtual environment](#create-a-virtual-environment) - [Install pip packages](#install-pip-packages) - - [Install ORT nightly package](#install-ort-nightly-package) + - [For AMD on Windows: Install ORT nightly package](#for-amd-on-windows-install-ort-nightly-package) + - [For CPU on Linux: Install CPU PyTorch and ONNX](#for-cpu-on-linux-install-cpu-pytorch-and-onnx) + - [For CPU on Windows: Install CPU PyTorch and ONNX](#for-cpu-on-windows-install-cpu-pytorch-and-onnx) + - [For Nvidia everywhere: Install GPU PyTorch and ONNX](#for-nvidia-everywhere-install-gpu-pytorch-and-onnx) - [Download and convert models](#download-and-convert-models) - [Usage](#usage) - [Configuring and running the server](#configuring-and-running-the-server) @@ -137,9 +140,9 @@ Update pip itself: Install the following packages for AI: ```shell -> pip install numpy>=1.20,<1.24 # version is important, 1.24 removed the deprecated np.float symbol -> pip install accelerate diffusers transformers ftfy spacy scipy -> pip install onnx onnxruntime torch +> pip install "numpy>=1.20,<1.24" +> pip install "protobuf<4,>=3.20.2" +> pip install accelerate diffusers ftfy onnx spacy scipy transformers ``` If you are running on Windows, install the DirectML ONNX runtime as well: @@ -160,27 +163,56 @@ _Or_ install all of these packages at once using [the `requirements.txt` file](. > pip install -r requirements.txt ``` -At the moment, only `numpy` seems to need a specific version. If you see an error about `np.float`, make sure you are -not using `numpy>=1.24`. [This SO question](https://stackoverflow.com/questions/74844262/how-to-solve-error-numpy-has-no-attribute-float-in-python) +At the moment, only `numpy` and `protobuf` seem to need a specific version. If you see an error about `np.float`, make +sure you are not using `numpy>=1.24`. +[This SO question](https://stackoverflow.com/questions/74844262/how-to-solve-error-numpy-has-no-attribute-float-in-python) has more details. -I got a warning about an incompatibility in `protobuf` when installing the `onnxruntime-directml` package, but have not seen any issues. Some of the gist guides recommend `diffusers=0.3.0`, but I had trouble with old versions of `diffusers` -before 0.6.0 or so. If I can determine a good set of working versions, I will pin them in `requirements.txt`. +#### For AMD on Windows: Install ORT nightly package -### Install ORT nightly package +You can optionally install the latest DirectML ORT nightly package, which may provide a substantial performance increase +(on my machine, the stable version takes about 30sec/image vs 9sec/image for the nightly). -Download the latest DirectML ORT nightly package for your version of Python and install it with pip. - -Downloads can be found at https://aiinfra.visualstudio.com/PublicPackages/_artifacts/feed/ORT-Nightly. If you are using -Python 3.10, download the `cp310` package. For Python 3.9, download the `cp39` package, and so on. +Downloads can be found at https://aiinfra.visualstudio.com/PublicPackages/_artifacts/feed/ORT-Nightly. You can install +through pip or download the package file. If you are using Python 3.10, download the `cp310` package. For Python 3.9, +download the `cp39` package, and so on. Installing with pip will figure out the correct version: ```shell -> pip install ~/Downloads/ort_nightly_directml-1.14.0.dev20221214001-cp310-cp310-win_amd64.whl --force-reinstall +> pip install --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/pypi/simple/ ort-nightly-directml --force-reinstall ``` Make sure to include the `--force-reinstall` flag, since it requires some older versions of other packages, and will overwrite the versions you currently have installed. +#### For CPU on Linux: Install CPU PyTorch and ONNX + +If you are running with a CPU and no hardware acceleration, install `onnxruntime` and the CPU version of PyTorch: + +```shell +> pip install onnxruntime +> pip install torch --extra-index-url https://download.pytorch.org/whl/cpu +``` + +#### For CPU on Windows: Install CPU PyTorch and ONNX + +If you are running with a CPU and no hardware acceleration, install `onnxruntime` and the CPU version of PyTorch: + +```shell +> pip install onnxruntime torch +``` + +#### For Nvidia everywhere: Install GPU PyTorch and ONNX + +If you are running with an Nvidia GPU, install `onnxruntime-gpu`: + +```shell +> pip install onnxruntime-gpu +> pip install torch --extra-index-url https://download.pytorch.org/whl/cu117 +``` + +Make sure you have CUDA 11.x installed and that the version of PyTorch matches the version of CUDA +([see their documentation](https://pytorch.org/get-started/locally/) for more details). + ### Download and convert models Sign up for an account at https://huggingface.co and find the models you want to use. Popular options include: diff --git a/api/requirements.txt b/api/requirements.txt index 8c4e22b4..f55f073f 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -4,6 +4,7 @@ diffusers numpy>=1.20,<1.24 onnx onnxruntime +protobuf<4,>=3.20.2 transformers ### Server packages ###