2023-08-03 14:36:50 +00:00
### Install Docker Server
> [!IMPORTANT]
> This was tested with Docker running on Linux. <br>If you can get it working on Windows or MacOS, please update this `README.md` with a PR!<br>
2023-05-31 16:00:31 +00:00
[Install Docker Engine ](https://docs.docker.com/engine/install )
2023-08-03 14:36:50 +00:00
## Simple Dockerfiles for building the llama-cpp-python server with external model bin files
### openblas_simple
A simple Dockerfile for non-GPU OpenBLAS, where the model is located outside the Docker image:
2023-06-02 11:03:19 +00:00
```
cd ./openblas_simple
docker build -t openblas_simple .
docker run -e USE_MLOCK=0 -e MODEL=/var/model/< model-path > -v < model-root-path > :/var/model -t openblas_simple
```
where `<model-root-path>/<model-path>` is the full path to the model file on the Docker host system.
2023-08-03 14:36:50 +00:00
### cuda_simple
> [!WARNING]
> Nvidia GPU CuBLAS support requires an Nvidia GPU with sufficient VRAM (approximately as much as the size in the table below) and Docker Nvidia support (see [container-toolkit/install-guide](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html)) <br>
A simple Dockerfile for CUDA-accelerated CuBLAS, where the model is located outside the Docker image:
2023-06-02 11:03:19 +00:00
```
cd ./cuda_simple
docker build -t cuda_simple .
2023-08-03 14:36:50 +00:00
docker run --gpus=all --cap-add SYS_RESOURCE -e USE_MLOCK=0 -e MODEL=/var/model/< model-path > -v < model-root-path > :/var/model -t cuda_simple
2023-06-02 11:03:19 +00:00
```
where `<model-root-path>/<model-path>` is the full path to the model file on the Docker host system.
2023-05-31 15:16:32 +00:00
2023-08-03 14:36:50 +00:00
--------------------------------------------------------------------------
### "Open-Llama-in-a-box"
Download an Apache V2.0 licensed 3B params Open LLaMA model and install into a Docker image that runs an OpenBLAS-enabled llama-cpp-python server:
2023-06-02 10:44:52 +00:00
```
$ cd ./open_llama
./build.sh
./start.sh
```
2023-08-03 14:36:50 +00:00
### Manually choose your own Llama model from Hugging Face
2023-06-02 11:08:59 +00:00
`python3 ./hug_model.py -a TheBloke -t llama`
You should now have a model in the current directory and `model.bin` symlinked to it for the subsequent Docker build and copy step. e.g.
2023-05-23 19:26:40 +00:00
```
docker $ ls -lh *.bin
2023-05-31 16:00:31 +00:00
-rw-rw-r-- 1 user user 4.8G May 23 18:30 < downloaded-model-file > q5_1.bin
lrwxrwxrwx 1 user user 24 May 23 18:30 model.bin -> < downloaded-model-file > q5_1.bin
2023-05-23 19:26:40 +00:00
```
2023-08-03 14:36:50 +00:00
> [!NOTE]
> Make sure you have enough disk space to download the model. As the model is then copied into the image you will need at least
**TWICE** as much disk space as the size of the model:< br >
2023-05-23 19:26:40 +00:00
| Model | Quantized size |
|------:|----------------:|
2023-06-02 08:48:54 +00:00
| 3B | 3 GB |
2023-05-23 19:26:40 +00:00
| 7B | 5 GB |
| 13B | 10 GB |
2023-06-02 08:48:54 +00:00
| 33B | 25 GB |
2023-05-23 19:26:40 +00:00
| 65B | 50 GB |
2023-08-03 14:36:50 +00:00
> [!NOTE]
> If you want to pass or tune additional parameters, customise `./start_server.sh` before running `docker build ...`