From 859dd8e71291091f5702a516f4fe66bac6930dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Baldo?= Date: Mon, 11 Dec 2023 17:40:27 -0300 Subject: [PATCH 1/3] Add a Dockerfile for the /hf benchmarks with instructions to build and run them. --- hf/Dockerfile | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 hf/Dockerfile diff --git a/hf/Dockerfile b/hf/Dockerfile new file mode 100644 index 0000000..25450da --- /dev/null +++ b/hf/Dockerfile @@ -0,0 +1,35 @@ +# From the parent directory (main directory of this repo) run: +# +# docker build --build-arg USERID=$(id -u) -t local/hf-bench hf +# +# If not already using and having a $HOME/.cache/huggingface/ then: +# +# mkdir $HOME/.cache/huggingface/ +# docker run --rm -it -v$HOME/.cache/huggingface/:/home/user/.cache/huggingface/ local/hf-bench \ +# huggingface-cli login +# Answer n to: Add token as git credential? (Y/n) n +# +# docker run --rm -it -v$HOME/.cache/huggingface/:/home/user/.cache/huggingface/ \ +# -v$(pwd):/home/user/llama-inference --gpus all local/hf-bench \ +# sh -c 'cd /home/user/llama-inference/hf && python3 bench.py' +# you can substitute bench.py by bench-bb.py, bench-gptq.py or any other. + +# Select an available version from +# https://gitlab.com/nvidia/container-images/cuda/blob/master/doc/supported-tags.md: +FROM nvidia/cuda:12.2.2-cudnn8-runtime-rockylinux9 + +RUN yum install -y \ + python3-pip cuda-cupti-$(echo $CUDA_VERSION | sed -r 's/(.+)[.](.+)[.].*/\1-\2/') && \ + yum clean all && rm -rf /var/cache/yum/* + +# 2023-12-07 giving ImportError regarding bitsandbytes and accelerate unless using --pre, also for +# some reason some package needs scipy: +RUN pip install --no-cache-dir --pre transformers accelerate optimum bitsandbytes auto_gptq scipy + +# PyTorch doesn't find it by default, /usr/local/lib64/ doesn't work neither: +RUN ln -s /usr/local/cuda-12/lib64/libcupti.so.12 /usr/lib64/ + +ARG USERID=1000 +RUN adduser -u $USERID user +USER user + From aae1a148839de0f4aa7fdaa49dc3fbdaf951221d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Baldo?= Date: Fri, 15 Dec 2023 18:43:44 -0300 Subject: [PATCH 2/3] Add instructions for Podman with CDI. --- hf/Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hf/Dockerfile b/hf/Dockerfile index 25450da..5aa958b 100644 --- a/hf/Dockerfile +++ b/hf/Dockerfile @@ -12,7 +12,12 @@ # docker run --rm -it -v$HOME/.cache/huggingface/:/home/user/.cache/huggingface/ \ # -v$(pwd):/home/user/llama-inference --gpus all local/hf-bench \ # sh -c 'cd /home/user/llama-inference/hf && python3 bench.py' -# you can substitute bench.py by bench-bb.py, bench-gptq.py or any other. +# +# You can substitute bench.py by bench-bb.py, bench-gptq.py or any other. +# If using Podman with CDI substitute +# --gpus all +# for +# --device nvidia.com/gpu=all --security-opt=label=disable # Select an available version from # https://gitlab.com/nvidia/container-images/cuda/blob/master/doc/supported-tags.md: From 345c0c7227adadcfc698044147a87d9fb0f70df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Baldo?= Date: Tue, 2 Apr 2024 13:19:55 -0300 Subject: [PATCH 3/3] No more need for pip --pre and libcupti symlink, fix dnf cleanup, explicit registry for new Podman. --- hf/Dockerfile | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/hf/Dockerfile b/hf/Dockerfile index 5aa958b..a440b86 100644 --- a/hf/Dockerfile +++ b/hf/Dockerfile @@ -21,18 +21,15 @@ # Select an available version from # https://gitlab.com/nvidia/container-images/cuda/blob/master/doc/supported-tags.md: -FROM nvidia/cuda:12.2.2-cudnn8-runtime-rockylinux9 +# 2024-04-02 PyTorch was compiled for CUDNN8: +#FROM nvcr.io/nvidia/cuda:12.3.2-cudnn9-runtime-rockylinux9 +FROM nvcr.io/nvidia/cuda:12.2.2-cudnn8-runtime-rockylinux9 -RUN yum install -y \ +RUN dnf install -y \ python3-pip cuda-cupti-$(echo $CUDA_VERSION | sed -r 's/(.+)[.](.+)[.].*/\1-\2/') && \ - yum clean all && rm -rf /var/cache/yum/* + dnf clean all && rm -rf /var/cache/dnf/* -# 2023-12-07 giving ImportError regarding bitsandbytes and accelerate unless using --pre, also for -# some reason some package needs scipy: -RUN pip install --no-cache-dir --pre transformers accelerate optimum bitsandbytes auto_gptq scipy - -# PyTorch doesn't find it by default, /usr/local/lib64/ doesn't work neither: -RUN ln -s /usr/local/cuda-12/lib64/libcupti.so.12 /usr/lib64/ +RUN pip install --no-cache-dir transformers accelerate optimum bitsandbytes auto_gptq scipy ARG USERID=1000 RUN adduser -u $USERID user