Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/NexaAI/nexaai-sdk-cpp into …
Browse files Browse the repository at this point in the history
…david/bugfix
  • Loading branch information
Davidqian123 committed Aug 22, 2024
2 parents bb9bfb6 + ae75950 commit 0bb00d0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 17 deletions.
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use a base image that includes Miniconda
FROM continuumio/miniconda3

# Set the working directory in the container
WORKDIR /app

RUN apt-get update && apt-get install -y cmake g++
# Copy the environment.yml file into the container at /app
COPY pyproject.toml CMakeLists.txt requirements.txt README.md ./
COPY dependency ./dependency

# Install the conda environment
RUN conda create -n nexa python=3.10 -y
RUN /bin/bash -c "source activate nexa && pip install -r requirements.txt && pip install -e ."

# Activate the environment
RUN echo "source activate nexa" > ~/.bashrc
ENV PATH /opt/conda/envs/nexa/bin:$PATH

# Copy your application code to the container
COPY . .

# Set the command to activate the environment and start your application
CMD ["bash", "-c", "source activate nexa && python -m nexa.cli.entry gen-text gemma"]
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Detailed API documentation is available [here](docs/index.html).

## Installation

**GPU version(optional)**
### GPU version(optional)

check if you have GPU acceleration (torch required)
<details>
Expand All @@ -38,11 +38,11 @@ check if you have GPU acceleration (torch required)
if True

```
CMAKE_ARGS="-DGGML_CUDA=on -DSD_CUBLAS=ON" pip install nexaai-gpu
CMAKE_ARGS="-DGGML_CUDA=on -DSD_CUBLAS=ON" pip install nexaai
```
Or you prefer to install our pre-built wheel:
```bash
pip install nexaai-cuda --index-url https://nexaai.github.io/nexa-sdk/whl/cu124 --extra-index-url https://pypi.org/simple
pip install nexaai --index-url https://nexaai.github.io/nexa-sdk/whl/cu124 --extra-index-url https://pypi.org/simple
```
</details>
<details>
Expand All @@ -52,24 +52,15 @@ check if you have GPU acceleration (torch required)
if True:

```
CMAKE_ARGS="-DGGML_METAL=on -DSD_METAL=ON" pip install nexaai-gpu
CMAKE_ARGS="-DGGML_METAL=on -DSD_METAL=ON" pip install nexaai
```
Or you prefer to install our pre-built wheel:
```bash
pip install nexaai-metal --index-url https://nexaai.github.io/nexa-sdk/whl/metal --extra-index-url https://pypi.org/simple
pip install nexaai --index-url https://nexaai.github.io/nexa-sdk/whl/metal --extra-index-url https://pypi.org/simple
```
</details>

<details>
<summary>AMD graphics card:</summary>


```
CMAKE_ARGS="-DGGML_HIPBLAS=on" pip install nexaai-gpu
```
</details>

**CPU version**
### CPU version

<details>
<summary>Mac with Intel chips</summary>
Expand All @@ -92,6 +83,22 @@ Or you prefer to install the pre-built wheel:
pip install nexaai --index-url https://nexaai.github.io/nexa-sdk/whl/cpu --extra-index-url https://pypi.org/simple
```

### Docker Usage
Note: Docker doesn't support GPU acceleration

`docker pull nexa4ai/sdk:latest`

replace following placeholder with your path and command

`docker run -v <your_model_dir>:/model -it nexa4ai/sdk:latest [nexa_command] [your_model_relative_path]`

Example:

`docker run -v /home/ubuntu/.cache/nexa/hub/official:/model -it nexa4ai/sdk:latest nexa gen-text /model/Phi-3-mini-128k-instruct/q4_0.gguf`

will create an interactive session with text generation
```
## Nexa CLI commands
## Model Commands
Expand Down
4 changes: 2 additions & 2 deletions nexa/onnx/nexa_inference_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class NexaImageInference:
A class used for loading image models and running image generation.
Methods:
run: Run the image generation loop.
run_streamlit: Run the Streamlit UI.
run: Run the image generation loop.
run_streamlit: Run the Streamlit UI.
Args:
model_path (str): Path or identifier for the model in Nexa Model Hub.
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ sdist.exclude = [".github", "build", "dist", "nexa.egg-info", "dependency/llama.
build.verbose = true
cmake.build-type = "Release"
cmake.version = ">=3.16"
cmake.args = ["-DCMAKE_CXX_FLAGS=-fopenmp"]

[tool.pytest.ini_options]
testpaths = ["tests"]

0 comments on commit 0bb00d0

Please sign in to comment.