-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker:nvidia opencl support with instructions
- Loading branch information
1 parent
32eac9e
commit faf98bd
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM debian:bookworm | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
RUN apt update -y | ||
RUN apt install -y curl \ | ||
apt-utils \ | ||
unzip \ | ||
tar \ | ||
curl \ | ||
xz-utils \ | ||
ocl-icd-libopencl1 \ | ||
opencl-headers \ | ||
clinfo \ | ||
build-essential \ | ||
gcc | ||
|
||
RUN mkdir -p /etc/OpenCL/vendors && \ | ||
echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd | ||
ENV NVIDIA_VISIBLE_DEVICES all | ||
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility | ||
|
||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /rustup.sh | ||
RUN chmod +x /rustup.sh | ||
RUN /rustup.sh -y | ||
|
||
RUN apt install -y opencl-dev | ||
|
||
RUN bash -c 'export PATH="$PATH:$HOME/.cargo/bin";rustup default nightly' | ||
|
||
COPY . /opt/rllama | ||
RUN bash -c 'export PATH="$PATH:$HOME/.cargo/bin";cd /opt/rllama;RUSTFLAGS="-C target-feature=+sse2,+avx,+fma,+avx2" cargo build --release --features server,opencl' | ||
RUN ln -s /opt/rllama/target/release/rllama /usr/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#rllama docker on nvidia | ||
|
||
## Getting OpenCL to work inside docker. | ||
Please note that this also requires some packages and modifications on your host system in order to allow the containers to use nvidia GPU features such as **compute**. | ||
|
||
|
||
For each of the described distro / distro-family you could follow the instructions at the given links below. | ||
|
||
**Note**: You also need an upto-date version of docker/docker-ce so be sure to follow the instructions to install docker for your distro from the [docker website](https://docs.docker.com/engine/install). | ||
|
||
**Note2**: I have only personally tested the instructions on fedora/nobara and hence, cannot guarantee the accuracy of the instructions for other distros. | ||
|
||
### Fedora / Fedora-based | ||
**[https://gist.github.com/JuanM04/fcbed16d0f4405a286adebee5fd31cb2](https://gist.github.com/JuanM04/fcbed16d0f4405a286adebee5fd31cb2)** | ||
|
||
|
||
### Debian / Debian-based / Ubuntu / Ubuntu-based | ||
**[https://www.howtogeek.com/devops/how-to-use-an-nvidia-gpu-with-docker-containers/](https://www.howtogeek.com/devops/how-to-use-an-nvidia-gpu-with-docker-containers/)** | ||
|
||
|
||
### Arch / Arch-based | ||
**[https://wiki.archlinux.org/title/Docker#Run_GPU_accelerated_Docker_containers_with_NVIDIA_GPUs](https://wiki.archlinux.org/title/Docker#Run_GPU_accelerated_Docker_containers_with_NVIDIA_GPUs)** | ||
|
||
Feel free to contribute/improve the instructions for existing and other distros. | ||
|
||
## Usage | ||
1. | ||
```bash | ||
docker build -f ./.docker/nvidia.dockerfile -t rllama:nvidia . | ||
``` | ||
2. | ||
```bash | ||
docker run --rm --gpus all --privileged -v /models/LLaMA:/models:z -it rllama:nvidia \ | ||
rllama --model-path /models/7B \ | ||
--param-path /models/7B/params.json \ | ||
--tokenizer-path /models/tokenizer.model \ | ||
--prompt "hi I like cheese" | ||
``` | ||
|
||
Replace `/models/LLaMA` with the directory you've downloaded your models to. The `:z` in `-v` flag may or may not be needed depending on your distribution (I needed it on Fedora Linux) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters