From 33959f8d94e2dd95967a7673756a38a760ef27fb Mon Sep 17 00:00:00 2001 From: jasl Date: Sun, 22 Oct 2023 22:51:50 +0800 Subject: [PATCH 01/14] Use entrypoint style for enduser apps --- jetson_containers/container.py | 1 + packages/diffusion/stable-diffusion-webui/Dockerfile | 6 ++++-- .../stable-diffusion-webui/docker-entrypoint.sh | 5 +++++ packages/jupyterlab/Dockerfile | 9 +++++---- packages/jupyterlab/docker-entrypoint.sh | 9 +++++++++ packages/llm/text-generation-webui/Dockerfile | 6 ++++-- packages/llm/text-generation-webui/docker-entrypoint.sh | 5 +++++ 7 files changed, 33 insertions(+), 8 deletions(-) create mode 100755 packages/diffusion/stable-diffusion-webui/docker-entrypoint.sh create mode 100755 packages/jupyterlab/docker-entrypoint.sh create mode 100755 packages/llm/text-generation-webui/docker-entrypoint.sh diff --git a/jetson_containers/container.py b/jetson_containers/container.py index 7053a6354..07034c054 100644 --- a/jetson_containers/container.py +++ b/jetson_containers/container.py @@ -295,6 +295,7 @@ def test_container(name, package, simulate=False): cmd += f"--volume {package['path']}:/test" + _NEWLINE_ cmd += f"--volume {os.path.join(_PACKAGE_ROOT, 'data')}:/data" + _NEWLINE_ cmd += f"--workdir /test" + _NEWLINE_ + cmd += f"--entrypoint /usr/bin/env" + _NEWLINE_ cmd += name + _NEWLINE_ cmd += "/bin/bash -c '" diff --git a/packages/diffusion/stable-diffusion-webui/Dockerfile b/packages/diffusion/stable-diffusion-webui/Dockerfile index 636744898..b4a240af7 100644 --- a/packages/diffusion/stable-diffusion-webui/Dockerfile +++ b/packages/diffusion/stable-diffusion-webui/Dockerfile @@ -34,6 +34,8 @@ RUN cd /opt/stable-diffusion-webui && \ # set the cache dir for models ENV DIFFUSERS_CACHE=/data/models/diffusers -# default start-up command -CMD /bin/bash -c "cd /opt/stable-diffusion-webui && python3 launch.py --data=/data/models/stable-diffusion --enable-insecure-extension-access --xformers --listen --port=7860" +COPY docker-entrypoint.sh /usr/local/bin +WORKDIR /opt/stable-diffusion-webui + +ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/packages/diffusion/stable-diffusion-webui/docker-entrypoint.sh b/packages/diffusion/stable-diffusion-webui/docker-entrypoint.sh new file mode 100755 index 000000000..125ef8cd7 --- /dev/null +++ b/packages/diffusion/stable-diffusion-webui/docker-entrypoint.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -e + +cd /opt/stable-diffusion-webui && python3 launch.py --data=/data/models/stable-diffusion --enable-insecure-extension-access --xformers --listen --port=7860 "$@" diff --git a/packages/jupyterlab/Dockerfile b/packages/jupyterlab/Dockerfile index c41495e22..cb94b3f0e 100644 --- a/packages/jupyterlab/Dockerfile +++ b/packages/jupyterlab/Dockerfile @@ -14,7 +14,8 @@ RUN pip3 install --no-cache-dir --verbose jupyter 'jupyterlab<4' && \ RUN jupyter lab --version && jupyter lab --generate-config RUN python3 -c "from notebook.auth.security import set_password; set_password('nvidia', '/root/.jupyter/jupyter_notebook_config.json')" -CMD /bin/bash -c "jupyter lab --ip 0.0.0.0 --port 8888 --allow-root &> /var/log/jupyter.log" & \ - echo "allow 10 sec for JupyterLab to start @ http://$(hostname -I | cut -d' ' -f1):8888 (password nvidia)" && \ - echo "JupterLab logging location: /var/log/jupyter.log (inside the container)" && \ - /bin/bash +COPY docker-entrypoint.sh /usr/local/bin + +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD ["/bin/bash"] diff --git a/packages/jupyterlab/docker-entrypoint.sh b/packages/jupyterlab/docker-entrypoint.sh new file mode 100755 index 000000000..7aac1c3d7 --- /dev/null +++ b/packages/jupyterlab/docker-entrypoint.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +jupyter lab --ip 0.0.0.0 --port 8888 --allow-root &> /var/log/jupyter.log & +echo "allow 10 sec for JupyterLab to start @ http://$(hostname -I | cut -d' ' -f1):8888 (password nvidia)" + +echo "JupterLab logging location: /var/log/jupyter.log (inside the container)" +exec "$@" diff --git a/packages/llm/text-generation-webui/Dockerfile b/packages/llm/text-generation-webui/Dockerfile index 5cba1e5ea..bc94f883b 100644 --- a/packages/llm/text-generation-webui/Dockerfile +++ b/packages/llm/text-generation-webui/Dockerfile @@ -83,6 +83,8 @@ ENV LD_PRELOAD=${LD_PRELOAD}:${LD_PRELOAD_LIBS} COPY settings.json text-generation-webui/ -WORKDIR / +COPY docker-entrypoint.sh /usr/local/bin -CMD /bin/bash -c "cd /opt/text-generation-webui && python3 server.py --model-dir=/data/models/text-generation-webui --listen --verbose" +WORKDIR /opt/text-generation-webui + +ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/packages/llm/text-generation-webui/docker-entrypoint.sh b/packages/llm/text-generation-webui/docker-entrypoint.sh new file mode 100755 index 000000000..49dcafaf0 --- /dev/null +++ b/packages/llm/text-generation-webui/docker-entrypoint.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -e + +cd /opt/text-generation-webui && python3 server.py --model-dir=/data/models/text-generation-webui --listen --verbose "$@" From 81ade1c63e31355eb2c4ce2e352f35749735b814 Mon Sep 17 00:00:00 2001 From: jasl Date: Sun, 22 Oct 2023 22:52:00 +0800 Subject: [PATCH 02/14] minor fix --- packages/audio/riva-client/Dockerfile.python | 3 +-- packages/tvm/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/audio/riva-client/Dockerfile.python b/packages/audio/riva-client/Dockerfile.python index 3105bfba7..5061ddfc9 100644 --- a/packages/audio/riva-client/Dockerfile.python +++ b/packages/audio/riva-client/Dockerfile.python @@ -39,5 +39,4 @@ RUN pip3 show nvidia-riva-client && python3 -c 'import riva.client; print(riva.c COPY list_audio_devices.py python-clients/scripts/ COPY loopback.py python-clients/scripts/ - -WORKDIR / \ No newline at end of file +WORKDIR / diff --git a/packages/tvm/Dockerfile b/packages/tvm/Dockerfile index f9b954279..800990e6e 100644 --- a/packages/tvm/Dockerfile +++ b/packages/tvm/Dockerfile @@ -73,4 +73,4 @@ RUN pip3 show tvm && python3 -c 'import tvm' ENV TVM_HOME=/opt/tvm -ln -s /opt/mlc-llm/3rdparty/tvm/3rdparty /usr/local/lib/python3.8/dist-packages/tvm/3rdparty \ No newline at end of file +RUN ln -s /opt/mlc-llm/3rdparty/tvm/3rdparty /usr/local/lib/python3.8/dist-packages/tvm/3rdparty From bbe167dfdc00b1a1241251faeb97bfb418f618cf Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Sun, 10 Dec 2023 03:17:56 +0800 Subject: [PATCH 03/14] Remove cuda-ubuntu2004.pin --- packages/cuda/cuda/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cuda/cuda/Dockerfile b/packages/cuda/cuda/Dockerfile index 55c3bc41e..3f0bd2476 100644 --- a/packages/cuda/cuda/Dockerfile +++ b/packages/cuda/cuda/Dockerfile @@ -25,7 +25,6 @@ RUN apt-get update && \ RUN echo "Downloading ${CUDA_DEB}" && \ mkdir /tmp/cuda && cd /tmp/cuda && \ - wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/arm64/cuda-ubuntu2004.pin -O /etc/apt/preferences.d/cuda-repository-pin-600 && \ wget --quiet --show-progress --progress=bar:force:noscroll ${CUDA_URL} && \ dpkg -i *.deb && \ cp /var/cuda-tegra-repo-*/cuda-tegra-*-keyring.gpg /usr/share/keyrings/ && \ From fefe623788bf1418d72b4bb3d6fbb0d95caa2ec8 Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Sun, 10 Dec 2023 03:47:07 +0800 Subject: [PATCH 04/14] Ubuntu 22.04 default is Python 3.10 --- packages/llm/text-generation-webui/config.py | 2 +- packages/llm/transformers/Dockerfile | 2 +- packages/nemo/config.py | 2 +- packages/rapids/raft/Dockerfile | 6 +++--- packages/ros/ros2_build.sh | 8 ++++---- packages/tvm/Dockerfile | 2 +- packages/vectordb/faiss/Dockerfile | 8 ++++---- packages/vit/tam/Dockerfile | 6 +++--- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/llm/text-generation-webui/config.py b/packages/llm/text-generation-webui/config.py index 002573a24..58ac7d624 100644 --- a/packages/llm/text-generation-webui/config.py +++ b/packages/llm/text-generation-webui/config.py @@ -33,6 +33,6 @@ def oobabooga(version, branch=None, tag=None, sha=None, build_args=None, default package = [ oobabooga('main', branch='main', default=True), - oobabooga('1.7', tag='v1.7', build_args=dict(LD_PRELOAD_LIBS='/usr/local/lib/python3.8/dist-packages/sklearn/__check_build/../../scikit_learn.libs/libgomp-d22c30c5.so.1.0.0')), + oobabooga('1.7', tag='v1.7', build_args=dict(LD_PRELOAD_LIBS='/usr/local/lib/python3.10/dist-packages/sklearn/__check_build/../../scikit_learn.libs/libgomp-d22c30c5.so.1.0.0')), oobabooga('6a7cd01', sha='6a7cd01ebf8021a8ee6da094643f09da41516ccd'), # last commit to support original server API ] \ No newline at end of file diff --git a/packages/llm/transformers/Dockerfile b/packages/llm/transformers/Dockerfile index 429b22bf7..fe623f464 100644 --- a/packages/llm/transformers/Dockerfile +++ b/packages/llm/transformers/Dockerfile @@ -25,7 +25,7 @@ RUN pip3 install --no-cache-dir --verbose \ RUN pip3 uninstall -y transformers && \ pip3 install --no-cache-dir --verbose ${TRANSFORMERS_PACKAGE} -# "/usr/local/lib/python3.8/dist-packages/transformers/modeling_utils.py", line 118 +# "/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py", line 118 # AttributeError: module 'torch.distributed' has no attribute 'is_initialized' RUN PYTHON_ROOT=`pip3 show transformers | grep Location: | cut -d' ' -f2` && \ sed -i 's|torch.distributed.is_initialized|torch.distributed.is_available|g' -i ${PYTHON_ROOT}/transformers/modeling_utils.py diff --git a/packages/nemo/config.py b/packages/nemo/config.py index f4a4582a6..1404a48db 100644 --- a/packages/nemo/config.py +++ b/packages/nemo/config.py @@ -10,5 +10,5 @@ package['depends'].extend(['rust', 'protobuf:apt']) elif L4T_VERSION.major <= 35: package['build_args'] = { - 'LD_PRELOAD_LIBS': '/usr/local/lib/python3.8/dist-packages/sklearn/__check_build/../../scikit_learn.libs/libgomp-d22c30c5.so.1.0.0' + 'LD_PRELOAD_LIBS': '/usr/local/lib/python3.10/dist-packages/sklearn/__check_build/../../scikit_learn.libs/libgomp-d22c30c5.so.1.0.0' } \ No newline at end of file diff --git a/packages/rapids/raft/Dockerfile b/packages/rapids/raft/Dockerfile index 9d75ae3a1..bbea80c9c 100644 --- a/packages/rapids/raft/Dockerfile +++ b/packages/rapids/raft/Dockerfile @@ -20,9 +20,9 @@ ARG BUILD_DIR=/opt/rapids WORKDIR ${BUILD_DIR} -RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \ - apt purge -y python3.9 libpython3.9* || echo "python3.9 not found, skipping removal" && \ - ls -ll /usr/bin/python* +# RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \ +# apt purge -y python3.9 libpython3.9* || echo "python3.9 not found, skipping removal" && \ +# ls -ll /usr/bin/python* ADD https://api.github.com/repos/${RAFT_REPO}/git/refs/heads/${RAFT_BRANCH} /tmp/raft_version.json diff --git a/packages/ros/ros2_build.sh b/packages/ros/ros2_build.sh index 7d14c62e7..410280d45 100755 --- a/packages/ros/ros2_build.sh +++ b/packages/ros/ros2_build.sh @@ -65,10 +65,10 @@ pip3 install --upgrade --no-cache-dir --verbose cmake cmake --version which cmake -# remove other versions of Python3 -# workaround for 'Could NOT find Python3 (missing: Python3_NumPy_INCLUDE_DIRS Development' -apt purge -y python3.9 libpython3.9* || echo "python3.9 not found, skipping removal" -ls -ll /usr/bin/python* +# # remove other versions of Python3 +# # workaround for 'Could NOT find Python3 (missing: Python3_NumPy_INCLUDE_DIRS Development' +# apt purge -y python3.9 libpython3.9* || echo "python3.9 not found, skipping removal" +# ls -ll /usr/bin/python* # create the ROS_ROOT directory mkdir -p ${ROS_ROOT}/src diff --git a/packages/tvm/Dockerfile b/packages/tvm/Dockerfile index 800990e6e..8f58ce192 100644 --- a/packages/tvm/Dockerfile +++ b/packages/tvm/Dockerfile @@ -73,4 +73,4 @@ RUN pip3 show tvm && python3 -c 'import tvm' ENV TVM_HOME=/opt/tvm -RUN ln -s /opt/mlc-llm/3rdparty/tvm/3rdparty /usr/local/lib/python3.8/dist-packages/tvm/3rdparty +RUN ln -s /opt/mlc-llm/3rdparty/tvm/3rdparty /usr/local/lib/python3.10/dist-packages/tvm/3rdparty diff --git a/packages/vectordb/faiss/Dockerfile b/packages/vectordb/faiss/Dockerfile index 9f07b9de8..1917fb794 100644 --- a/packages/vectordb/faiss/Dockerfile +++ b/packages/vectordb/faiss/Dockerfile @@ -23,10 +23,10 @@ RUN apt-get update && \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean -# workaround for 'Could NOT find Python3 (missing: Python3_NumPy_INCLUDE_DIRS Development' -# update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \ -RUN apt purge -y python3.9 libpython3.9* || echo "python3.9 not found, skipping removal" && \ - ls -ll /usr/bin/python* +# # workaround for 'Could NOT find Python3 (missing: Python3_NumPy_INCLUDE_DIRS Development' +# # update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \ +# RUN apt purge -y python3.9 libpython3.9* || echo "python3.9 not found, skipping removal" && \ +# ls -ll /usr/bin/python* ADD https://api.github.com/repos/${FAISS_REPO}/git/refs/heads/${FAISS_BRANCH} /tmp/faiss_version.json diff --git a/packages/vit/tam/Dockerfile b/packages/vit/tam/Dockerfile index 766b6bb76..63b40eb51 100644 --- a/packages/vit/tam/Dockerfile +++ b/packages/vit/tam/Dockerfile @@ -18,7 +18,7 @@ RUN git clone https://github.com/gaomingqi/Track-Anything.git && \ sed 's|^opencv-python||g' -i requirements.txt && \ pip3 install -r requirements.txt -RUN LD_LIBRARY_PATH=/usr/local/lib/python3.8/dist-packages/opencv_python.libs/:$LD_LIBRARY_PATH +RUN LD_LIBRARY_PATH=/usr/local/lib/python3.10/dist-packages/opencv_python.libs/:$LD_LIBRARY_PATH RUN cd /opt/Track-Anything && \ sed 's|cuda:3|cuda:0|g' -i app.py @@ -29,11 +29,11 @@ RUN cd /opt/Track-Anything && \ RUN pip3 install opencv-python==4.5.4.60 ENV LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1 -ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python3.8/dist-packages/opencv_python.libs/ +ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python3.10/dist-packages/opencv_python.libs/ RUN python3 -c 'import torch; print(f"PyTorch version: {torch.__version__}"); print(f"CUDA available: {torch.cuda.is_available()}"); print(f"cuDNN version: {torch.backends.cudnn.version()}"); print(f"torch.distributed: {torch.distributed.is_available()}"); print(torch.__config__.show());' -ENV CPP_EXTENSION_PY_FILE=/usr/local/lib/python3.8/dist-packages/torch/utils/cpp_extension.py +ENV CPP_EXTENSION_PY_FILE=/usr/local/lib/python3.10/dist-packages/torch/utils/cpp_extension.py RUN sed "s|('Ampere', '8.0;8.6+PTX'),|('Ampere', '8.0;8.6+PTX'),('Ampere+Tegra', '8.7'),|" -i ${CPP_EXTENSION_PY_FILE} RUN sed "s|'8.6', '8.9'|'8.6', '8.7', '8.9'|" -i ${CPP_EXTENSION_PY_FILE} RUN sed -n 1729,1746p ${CPP_EXTENSION_PY_FILE} From b88e0866ff4fd2ffbab294fc626ad6a703b2888c Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Fri, 15 Dec 2023 07:09:01 +0800 Subject: [PATCH 05/14] Install python-is-python3 --- packages/python/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/python/Dockerfile b/packages/python/Dockerfile index 2e55dd0b7..7f6e29606 100644 --- a/packages/python/Dockerfile +++ b/packages/python/Dockerfile @@ -14,6 +14,7 @@ RUN apt-get update && \ apt-get install -y --no-install-recommends \ python3-dev \ python3-pip \ + python-is-python3 \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean From b62be67eb2f2d60966232d4c56a929cf9ef3a764 Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Sun, 10 Dec 2023 03:57:43 +0800 Subject: [PATCH 06/14] Use ONNX v1.15.0, the old issue was resolved for a long time --- packages/onnx/config.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/onnx/config.py b/packages/onnx/config.py index 6dafe83aa..46332f557 100644 --- a/packages/onnx/config.py +++ b/packages/onnx/config.py @@ -2,8 +2,7 @@ from jetson_containers import L4T_VERSION if L4T_VERSION.major >= 34: # JetPack 5 - # https://github.com/onnx/onnx/issues/5346 - package['build_args'] = {'ONNX_VERSION': 'main'} + package['build_args'] = {'ONNX_VERSION': 'v1.15.0'} else: # onnx 1.15: SyntaxError: future feature annotations is not defined (/onnx/__init__.py", line 5) # onnx 1.14: onnx/defs/shape_inference.h:828:8: error: 'transform' is not a member of 'std' From e243ebd8f435f56ff29eb17ff0c2e956757cc01a Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Sun, 10 Dec 2023 07:35:32 +0800 Subject: [PATCH 07/14] Correct to use libtbb12 --- .../opencv/opencv_builder/opencv_install_deps.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/opencv/opencv_builder/opencv_install_deps.sh b/packages/opencv/opencv_builder/opencv_install_deps.sh index 6188af5ec..de0b4464f 100755 --- a/packages/opencv/opencv_builder/opencv_install_deps.sh +++ b/packages/opencv/opencv_builder/opencv_install_deps.sh @@ -13,11 +13,11 @@ fi apt-get update apt-get install -y --no-install-recommends \ build-essential \ - gfortran \ + gfortran \ cmake \ git \ - file \ - tar \ + file \ + tar \ libatlas-base-dev \ libavcodec-dev \ libavformat-dev \ @@ -38,20 +38,20 @@ apt-get install -y --no-install-recommends \ libpostproc-dev \ libswscale-dev \ libtbb-dev \ - libtbb2 \ + libtbb12 \ libtesseract-dev \ libtiff-dev \ libv4l-dev \ libxine2-dev \ libxvidcore-dev \ libx264-dev \ - libgtkglext1 \ - libgtkglext1-dev \ + libgtkglext1 \ + libgtkglext1-dev \ pkg-config \ qv4l2 \ v4l-utils \ zlib1g-dev \ - $EXTRAS + $EXTRAS # on x86, the python dev packages are already installed in the NGC containers under conda # and installing them again from apt messes up their proper detection, so skip doing that From dee0e01e722664da68a8b77434426e81ec6bc587 Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Fri, 15 Dec 2023 07:06:47 +0800 Subject: [PATCH 08/14] Update bitsandbytes --- packages/llm/bitsandbytes/Dockerfile | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/packages/llm/bitsandbytes/Dockerfile b/packages/llm/bitsandbytes/Dockerfile index 4aba3bf43..1d9ff87fc 100644 --- a/packages/llm/bitsandbytes/Dockerfile +++ b/packages/llm/bitsandbytes/Dockerfile @@ -1,7 +1,7 @@ #--- # name: bitsandbytes # group: llm -# requires: '==35.*' +# requires: '>=35.*' # depends: [transformers] # test: test.py # notes: fork of https://github.com/TimDettmers/bitsandbytes for Jetson @@ -10,23 +10,22 @@ ARG BASE_IMAGE FROM ${BASE_IMAGE} # upstream version is https://github.com/TimDettmers/bitsandbytes (the fork below includes some patches for Jetson) -ARG BITSANDBYTES_REPO=dusty-nv/bitsandbytes -ARG BITSANDBYTES_BRANCH=main +ARG BITSANDBYTES_REPO=jasl/bitsandbytes +ARG BITSANDBYTES_BRANCH=jetson # force rebuild on new git commits - https://stackoverflow.com/a/56945508 ADD https://api.github.com/repos/${BITSANDBYTES_REPO}/git/refs/heads/${BITSANDBYTES_BRANCH} /tmp/bitsandbytes_version.json -RUN pip3 uninstall -y bitsandbytes && \ - cd /opt && \ - git clone --depth=1 https://github.com/${BITSANDBYTES_REPO} bitsandbytes && \ - cd bitsandbytes && \ - CUDA_VERSION=114 make -j$(nproc) cuda11x && \ - CUDA_VERSION=114 make -j$(nproc) cuda11x_nomatmul && \ - python3 setup.py --verbose build_ext --inplace -j$(nproc) bdist_wheel && \ - cp dist/bitsandbytes*.whl /opt && \ - pip3 install --no-cache-dir --verbose /opt/bitsandbytes*.whl && \ - cd ../ && \ - rm -rf bitsandbytes +WORKDIR /opt + +RUN git clone --branch=${BITSANDBYTES_BRANCH} --depth=1 https://github.com/${BITSANDBYTES_REPO} bitsandbytes +RUN cd bitsandbytes && \ + CUDA_VERSION=122 make -j$(nproc) cuda12x && \ + CUDA_VERSION=122 make -j$(nproc) cuda12x_nomatmul && \ + pip3 wheel --wheel-dir=dist --no-deps --verbose . && \ + cp dist/bitsandbytes*.whl /opt + +RUN pip3 install --no-cache-dir --verbose --no-build-isolation /opt/bitsandbytes*.whl RUN pip3 install --no-cache-dir --verbose scipy RUN pip3 show bitsandbytes && python3 -c 'import bitsandbytes' From 1901c91d94e936bb1ec37c3d16ad877e67eefea4 Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Fri, 15 Dec 2023 07:08:38 +0800 Subject: [PATCH 09/14] Latest huggingface_hub changes TRANSFORMERS_CACHE to HF_HOME --- packages/llm/huggingface_hub/Dockerfile | 1 - packages/llm/huggingface_hub/huggingface-downloader.py | 2 +- packages/llm/local_llm/utils/model.py | 8 ++++---- packages/vectordb/nanodb/utils.py | 8 ++++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/llm/huggingface_hub/Dockerfile b/packages/llm/huggingface_hub/Dockerfile index 84e42fc2e..f2db466af 100644 --- a/packages/llm/huggingface_hub/Dockerfile +++ b/packages/llm/huggingface_hub/Dockerfile @@ -15,7 +15,6 @@ RUN pip3 install --no-cache-dir --verbose huggingface_hub[cli] RUN pip3 install --no-cache-dir --verbose dataclasses # set the model cache dir -ENV TRANSFORMERS_CACHE=/data/models/huggingface ENV HUGGINGFACE_HUB_CACHE=/data/models/huggingface ENV HF_HOME=/data/models/huggingface diff --git a/packages/llm/huggingface_hub/huggingface-downloader.py b/packages/llm/huggingface_hub/huggingface-downloader.py index aa732fd8c..bf0a28f74 100755 --- a/packages/llm/huggingface_hub/huggingface-downloader.py +++ b/packages/llm/huggingface_hub/huggingface-downloader.py @@ -11,7 +11,7 @@ parser.add_argument('--type', type=str, default='model', choices=['model', 'dataset'], help="'model' or 'dataset'") parser.add_argument('--token', type=str, default=os.environ.get('HUGGINGFACE_TOKEN', ''), help="HuggingFace account login token from https://huggingface.co/docs/hub/security-tokens (defaults to $HUGGINGFACE_TOKEN)") -parser.add_argument('--cache-dir', type=str, default=os.environ.get('TRANSFORMERS_CACHE', '/root/.cache/huggingface'), help="Location to download the repo to (defaults to $TRANSFORMERS_CACHE)") +parser.add_argument('--cache-dir', type=str, default=os.environ.get('HF_HOME', '/root/.cache/huggingface'), help="Location to download the repo to (defaults to $HF_HOME)") parser.add_argument('--location-file', type=str, default='/tmp/hf_download', help="file to write the local location/path of the downloaded repo(s) to") parser.add_argument('--allow-patterns', type=str, default='', help="comma-separated list of file patterns to download (enclose in single quotes if using wildcards)") diff --git a/packages/llm/local_llm/utils/model.py b/packages/llm/local_llm/utils/model.py index efbc81d5d..226e37723 100644 --- a/packages/llm/local_llm/utils/model.py +++ b/packages/llm/local_llm/utils/model.py @@ -4,11 +4,11 @@ from huggingface_hub import snapshot_download, hf_hub_download, login -def download_model(model, type='model', cache_dir='$TRANSFORMERS_CACHE', use_safetensors=False, **kwargs): +def download_model(model, type='model', cache_dir='$HF_HOME', use_safetensors=False, **kwargs): """ Get the local path to a cached model or file in the cache_dir, or download it from HuggingFace Hub if needed. If the asset is private and authentication is required, set the HUGGINGFACE_TOKEN environment variable. - cache_dir is where the model gets downloaded to - by default, set to $TRANSFORMERS_CACHE (/data/models/huggingface) + cache_dir is where the model gets downloaded to - by default, set to $HF_HOME (/data/models/huggingface) By default, the PyTorch .bin weights will be downloaded instead of the .safetensors (use_safetensors=False) """ token = os.environ.get('HUGGINGFACE_TOKEN', os.environ.get('HUGGING_FACE_HUB_TOKEN')) @@ -16,8 +16,8 @@ def download_model(model, type='model', cache_dir='$TRANSFORMERS_CACHE', use_saf if token: login(token=token) - if not cache_dir or cache_dir == '$TRANSFORMERS_CACHE': - cache_dir = os.environ.get('TRANSFORMERS_CACHE', '/root/.cache/huggingface') + if not cache_dir or cache_dir == '$HF_HOME': + cache_dir = os.environ.get('HF_HOME', '/root/.cache/huggingface') # handle either "org/repo" or individual "org/repo/file" # the former has 0-1 slashes, while the later has 2. diff --git a/packages/vectordb/nanodb/utils.py b/packages/vectordb/nanodb/utils.py index 11befc697..f230c47f2 100644 --- a/packages/vectordb/nanodb/utils.py +++ b/packages/vectordb/nanodb/utils.py @@ -73,19 +73,19 @@ def load_prompts(prompts): return prompt_list -def download_model(model, type='model', cache_dir='$TRANSFORMERS_CACHE'): +def download_model(model, type='model', cache_dir='$HF_HOME'): """ Get the local path to a cached model or file in the cache_dir, or download it from HuggingFace Hub if needed. If the asset is private and authentication is required, set the HUGGINGFACE_TOKEN environment variable. - cache_dir is where the model gets downloaded to - by default, set to $TRANSFORMERS_CACHE (/data/models/huggingface) + cache_dir is where the model gets downloaded to - by default, set to $HF_HOME (/data/models/huggingface) """ token = os.environ.get('HUGGINGFACE_TOKEN', os.environ.get('HUGGING_FACE_HUB_TOKEN')) if token: login(token=token) - if not cache_dir or cache_dir == '$TRANSFORMERS_CACHE': - cache_dir = os.environ.get('TRANSFORMERS_CACHE', '/root/.cache/huggingface') + if not cache_dir or cache_dir == '$HF_HOME': + cache_dir = os.environ.get('HF_HOME', '/root/.cache/huggingface') # handle either "org/repo" or individual "org/repo/file" # the former has 0-1 slashes, while the later has 2. From 3581be0eef5529216677cfbc61ab0a79f6a4c067 Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Fri, 15 Dec 2023 07:09:26 +0800 Subject: [PATCH 10/14] Add flash_attn --- packages/llm/flash_attn/Dockerfile | 23 ++++++ packages/llm/flash_attn/README.md | 122 +++++++++++++++++++++++++++++ packages/llm/flash_attn/docs.md | 50 ++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 packages/llm/flash_attn/Dockerfile create mode 100644 packages/llm/flash_attn/README.md create mode 100644 packages/llm/flash_attn/docs.md diff --git a/packages/llm/flash_attn/Dockerfile b/packages/llm/flash_attn/Dockerfile new file mode 100644 index 000000000..e1c43b049 --- /dev/null +++ b/packages/llm/flash_attn/Dockerfile @@ -0,0 +1,23 @@ +#--- +# name: flash_attn +# group: llm +# docs: docs.md +# depends: [pytorch] +# requires: '>=34.1.0' +#--- +ARG BASE_IMAGE +FROM ${BASE_IMAGE} + +ARG FLASH_ATTN_REPO=jasl/flash-attention +ARG FLASH_ATTN_BRANCH=aarch64 + +ADD https://api.github.com/repos/${FLASH_ATTN_REPO}/git/refs/heads/${FLASH_ATTN_BRANCH} /tmp/flash_attn_version.json + +WORKDIR /opt + +RUN git clone --branch=${FLASH_ATTN_BRANCH} --depth=1 https://github.com/${FLASH_ATTN_REPO} --recursive flash_attn +RUN cd flash_attn && \ + MAX_JOBS=8 FORCE_BUILD=True CUDA_GENCODE='arch=compute_87,code=sm_87' pip3 wheel --wheel-dir=dist --no-deps --verbose . && \ + cp dist/flash_attn*.whl /opt + +RUN pip3 install --no-cache-dir --verbose --no-build-isolation flash_attn*.whl diff --git a/packages/llm/flash_attn/README.md b/packages/llm/flash_attn/README.md new file mode 100644 index 000000000..2f65115df --- /dev/null +++ b/packages/llm/flash_attn/README.md @@ -0,0 +1,122 @@ +# flash-attn + +> [`CONTAINERS`](#user-content-containers) [`IMAGES`](#user-content-images) [`RUN`](#user-content-run) [`BUILD`](#user-content-build) + + +* LLaVa vision LLM from https://github.com/haotian-liu/LLaVA +* See [jetson-ai-lab.com/tutorial_llava.html](https://www.jetson-ai-lab.com/tutorial_llava.html) to use quantized with text-generation-webui + + + +These are with `llava-llama-2` models, however `llava-1.5` is now the latest and can be use instead. + +### llava-llama-2-7b-chat + +This is a LoRA applied to the original llama-2-7b-chat model, hence you need to [request access](https://huggingface.co/meta-llama) and provide your [HuggingFace token](https://huggingface.co/docs/hub/security-tokens) (or use [`SaffalPoosh/llava-llama-2-7B-merged`](https://huggingface.co/SaffalPoosh/llava-llama-2-7B-merged) instead) + +```bash +./run.sh --env HUGGING_FACE_HUB_TOKEN= $(./autotag llava) \ + python3 -m llava.serve.cli \ + --model-path liuhaotian/llava-llama-2-7b-chat-lightning-lora-preview \ + --model-base meta-llama/Llama-2-7b-chat-hf \ + --image-file /data/images/hoover.jpg +``` + +``` +USER: what does the road sign say? +ASSISTANT: The road sign says "Hoover Dam." + +USER: how far away is the exit? +ASSISTANT: The exit is 1 mile away. + +USER: what is the environment like? +ASSISTANT: The environment is desert-like, with a rocky landscape and a dirt road leading to the exit. +``` + +### llava-llama-2-13b-chat + +```bash +./run.sh $(./autotag llava) \ + python3 -m llava.serve.cli \ + --model-path liuhaotian/llava-llama-2-13b-chat-lightning-preview \ + --image-file /data/images/hoover.jpg +``` + +``` +USER: what does the text in the road sign say? +ASSISTANT: The text in the road sign says "Hoover Dam Exit 2 Mile." + +USER: How far away is the exit? +ASSISTANT: The exit is two miles away from the current location. + +USER: What kind of environment is it? +ASSISTANT: The environment is a desert setting, with a mountain in the background. +``` + +
+CONTAINERS +
+ +| **`llava`** | | +| :-- | :-- | +|    Builds | [![`llava_jp51`](https://img.shields.io/github/actions/workflow/status/dusty-nv/jetson-containers/llava_jp51.yml?label=llava:jp51)](https://github.com/dusty-nv/jetson-containers/actions/workflows/llava_jp51.yml) | +|    Requires | `L4T >=34.1.0` | +|    Dependencies | [`build-essential`](/packages/build-essential) [`cuda`](/packages/cuda/cuda) [`cudnn`](/packages/cuda/cudnn) [`python`](/packages/python) [`tensorrt`](/packages/tensorrt) [`numpy`](/packages/numpy) [`cmake`](/packages/cmake/cmake_pip) [`onnx`](/packages/onnx) [`pytorch`](/packages/pytorch) [`torchvision`](/packages/pytorch/torchvision) [`huggingface_hub`](/packages/llm/huggingface_hub) [`rust`](/packages/rust) [`transformers`](/packages/llm/transformers) | +|    Dockerfile | [`Dockerfile`](Dockerfile) | +|    Images | [`dustynv/llava:r35.2.1`](https://hub.docker.com/r/dustynv/llava/tags) `(2023-12-06, 6.3GB)`
[`dustynv/llava:r35.3.1`](https://hub.docker.com/r/dustynv/llava/tags) `(2023-10-05, 6.1GB)`
[`dustynv/llava:r35.4.1`](https://hub.docker.com/r/dustynv/llava/tags) `(2023-10-07, 6.0GB)` | + +
+ +
+CONTAINER IMAGES +
+ +| Repository/Tag | Date | Arch | Size | +| :-- | :--: | :--: | :--: | +|   [`dustynv/llava:r35.2.1`](https://hub.docker.com/r/dustynv/llava/tags) | `2023-12-06` | `arm64` | `6.3GB` | +|   [`dustynv/llava:r35.3.1`](https://hub.docker.com/r/dustynv/llava/tags) | `2023-10-05` | `arm64` | `6.1GB` | +|   [`dustynv/llava:r35.4.1`](https://hub.docker.com/r/dustynv/llava/tags) | `2023-10-07` | `arm64` | `6.0GB` | + +> Container images are compatible with other minor versions of JetPack/L4T:
+>     • L4T R32.7 containers can run on other versions of L4T R32.7 (JetPack 4.6+)
+>     • L4T R35.x containers can run on other versions of L4T R35.x (JetPack 5.1+)
+
+ +
+RUN CONTAINER +
+ +To start the container, you can use the [`run.sh`](/docs/run.md)/[`autotag`](/docs/run.md#autotag) helpers or manually put together a [`docker run`](https://docs.docker.com/engine/reference/commandline/run/) command: +```bash +# automatically pull or build a compatible container image +./run.sh $(./autotag llava) + +# or explicitly specify one of the container images above +./run.sh dustynv/llava:r35.2.1 + +# or if using 'docker run' (specify image and mounts/ect) +sudo docker run --runtime nvidia -it --rm --network=host dustynv/llava:r35.2.1 +``` +> [`run.sh`](/docs/run.md) forwards arguments to [`docker run`](https://docs.docker.com/engine/reference/commandline/run/) with some defaults added (like `--runtime nvidia`, mounts a `/data` cache, and detects devices)
+> [`autotag`](/docs/run.md#autotag) finds a container image that's compatible with your version of JetPack/L4T - either locally, pulled from a registry, or by building it. + +To mount your own directories into the container, use the [`-v`](https://docs.docker.com/engine/reference/commandline/run/#volume) or [`--volume`](https://docs.docker.com/engine/reference/commandline/run/#volume) flags: +```bash +./run.sh -v /path/on/host:/path/in/container $(./autotag llava) +``` +To launch the container running a command, as opposed to an interactive shell: +```bash +./run.sh $(./autotag llava) my_app --abc xyz +``` +You can pass any options to [`run.sh`](/docs/run.md) that you would to [`docker run`](https://docs.docker.com/engine/reference/commandline/run/), and it'll print out the full command that it constructs before executing it. +
+
+BUILD CONTAINER +
+ +If you use [`autotag`](/docs/run.md#autotag) as shown above, it'll ask to build the container for you if needed. To manually build it, first do the [system setup](/docs/setup.md), then run: +```bash +./build.sh llava +``` +The dependencies from above will be built into the container, and it'll be tested during. See [`./build.sh --help`](/jetson_containers/build.py) for build options. +
diff --git a/packages/llm/flash_attn/docs.md b/packages/llm/flash_attn/docs.md new file mode 100644 index 000000000..65a590fc5 --- /dev/null +++ b/packages/llm/flash_attn/docs.md @@ -0,0 +1,50 @@ + +* LLaVa vision LLM from https://github.com/haotian-liu/LLaVA +* See [jetson-ai-lab.com/tutorial_llava.html](https://www.jetson-ai-lab.com/tutorial_llava.html) to use quantized with text-generation-webui + + + +These are with `llava-llama-2` models, however `llava-1.5` is now the latest and can be use instead. + +### llava-llama-2-7b-chat + +This is a LoRA applied to the original llama-2-7b-chat model, hence you need to [request access](https://huggingface.co/meta-llama) and provide your [HuggingFace token](https://huggingface.co/docs/hub/security-tokens) (or use [`SaffalPoosh/llava-llama-2-7B-merged`](https://huggingface.co/SaffalPoosh/llava-llama-2-7B-merged) instead) + +```bash +./run.sh --env HUGGING_FACE_HUB_TOKEN= $(./autotag llava) \ + python3 -m llava.serve.cli \ + --model-path liuhaotian/llava-llama-2-7b-chat-lightning-lora-preview \ + --model-base meta-llama/Llama-2-7b-chat-hf \ + --image-file /data/images/hoover.jpg +``` + +``` +USER: what does the road sign say? +ASSISTANT: The road sign says "Hoover Dam." + +USER: how far away is the exit? +ASSISTANT: The exit is 1 mile away. + +USER: what is the environment like? +ASSISTANT: The environment is desert-like, with a rocky landscape and a dirt road leading to the exit. +``` + +### llava-llama-2-13b-chat + +```bash +./run.sh $(./autotag llava) \ + python3 -m llava.serve.cli \ + --model-path liuhaotian/llava-llama-2-13b-chat-lightning-preview \ + --image-file /data/images/hoover.jpg +``` + +``` +USER: what does the text in the road sign say? +ASSISTANT: The text in the road sign says "Hoover Dam Exit 2 Mile." + +USER: How far away is the exit? +ASSISTANT: The exit is two miles away from the current location. + +USER: What kind of environment is it? +ASSISTANT: The environment is a desert setting, with a mountain in the background. +``` From 3d83e3981b7c9c0442de263c89b78f57c972778d Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Sat, 16 Dec 2023 10:26:13 +0800 Subject: [PATCH 11/14] TF use protobuf from pip --- packages/tensorflow/Dockerfile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/tensorflow/Dockerfile b/packages/tensorflow/Dockerfile index f612e5106..e61f082b4 100644 --- a/packages/tensorflow/Dockerfile +++ b/packages/tensorflow/Dockerfile @@ -1,7 +1,7 @@ #--- # name: tensorflow # group: ml -# depends: [cuda, cudnn, tensorrt, python, numpy, protobuf:cpp] +# depends: [cuda, cudnn, tensorrt, python, numpy] # test: test.py # docs: | # Container for TF1/TF2 with CUDA support. @@ -12,7 +12,6 @@ ARG BASE_IMAGE FROM ${BASE_IMAGE} - # setup environment ENV DEBIAN_FRONTEND=noninteractive ARG HDF5_DIR="/usr/lib/aarch64-linux-gnu/hdf5/serial/" @@ -20,7 +19,6 @@ ARG MAKEFLAGS=-j$(nproc) RUN printenv - # install prerequisites - https://docs.nvidia.com/deeplearning/frameworks/install-tf-jetson-platform/index.html#prereqs RUN apt-get update && \ apt-get install -y --no-install-recommends \ @@ -36,11 +34,9 @@ RUN apt-get update && \ RUN pip3 install --no-cache-dir setuptools Cython wheel - # install Python TF dependencies RUN H5PY_SETUP_REQUIRES=0 pip3 install --no-cache-dir --verbose h5py -RUN pip3 install --no-cache-dir --verbose future==0.18.2 mock==3.0.5 keras_preprocessing==1.1.2 keras_applications==1.0.8 gast==0.4.0 futures pybind11 - +RUN pip3 install --no-cache-dir --verbose future==0.18.2 mock==3.0.5 keras_preprocessing==1.1.2 keras_applications==1.0.8 gast==0.4.0 futures pybind11 protobuf # TensorFlow ARG TENSORFLOW_URL From 79d0ed7be7928336823c3a4b81b0f5795e1fbe81 Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Sat, 16 Dec 2023 17:32:45 +0800 Subject: [PATCH 12/14] Use newer protobuf for ONNX --- packages/onnx/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/onnx/Dockerfile b/packages/onnx/Dockerfile index 42475b8ef..6b67d14a6 100644 --- a/packages/onnx/Dockerfile +++ b/packages/onnx/Dockerfile @@ -14,7 +14,7 @@ ARG ONNX_VERSION # error introduced by https://github.com/onnx/onnx/pull/5777 results in python protobuf mismatch # https://github.com/onnx/onnx/blob/6ff456c1179c34827ad910e5601cb1486822d800/CMakeLists.txt#L249 RUN if [ `lsb_release --codename --short` != 'bionic' ]; then \ - pip3 install --no-cache-dir --verbose protobuf==4.22.3; \ + pip3 install --no-cache-dir --verbose protobuf>=4.22.3; \ fi RUN pip3 install --no-cache-dir --verbose git+https://github.com/onnx/onnx@${ONNX_VERSION} From 6d5f32f6fd5a9569360301800d6bc909c81347ab Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Sun, 17 Dec 2023 05:32:33 +0800 Subject: [PATCH 13/14] Add env `DATA_VOLUME_PATH` to change data path --- run.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index 30adbc822..d106657d7 100755 --- a/run.sh +++ b/run.sh @@ -3,6 +3,8 @@ # https://docs.docker.com/engine/reference/commandline/run/ ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +DATA_VOLUME_PATH="${DATA_VOLUME_PATH:-"$ROOT/data"}" + # check for V4L2 devices V4L2_DEVICES="" @@ -51,7 +53,7 @@ if [ $ARCH = "aarch64" ]; then --volume /etc/enctune.conf:/etc/enctune.conf \ --volume /etc/nv_tegra_release:/etc/nv_tegra_release \ --volume /tmp/nv_jetson_model:/tmp/nv_jetson_model \ - --volume $ROOT/data:/data \ + --volume $DATA_VOLUME_PATH:/data \ --device /dev/snd \ --device /dev/bus/usb \ $DATA_VOLUME $DISPLAY_DEVICE $V4L2_DEVICES \ @@ -66,7 +68,7 @@ elif [ $ARCH = "x86_64" ]; then --ulimit memlock=-1 \ --ulimit stack=67108864 \ --env NVIDIA_DRIVER_CAPABILITIES=all \ - --volume $ROOT/data:/data \ + --volume $DATA_VOLUME_PATH:/data \ $DATA_VOLUME $DISPLAY_DEVICE $V4L2_DEVICES \ "$@" fi From 6726d628f50a35b34349889efff2f601b660fe80 Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Sun, 10 Dec 2023 02:44:13 +0800 Subject: [PATCH 14/14] Add sd-next, a popular fork of stable-diffusion-webui --- packages/diffusion/sd-next/Dockerfile | 38 ++++++ packages/diffusion/sd-next/README.md | 110 ++++++++++++++++++ .../diffusion/sd-next/docker-entrypoint.sh | 14 +++ packages/diffusion/sd-next/docs.md | 36 ++++++ 4 files changed, 198 insertions(+) create mode 100644 packages/diffusion/sd-next/Dockerfile create mode 100644 packages/diffusion/sd-next/README.md create mode 100755 packages/diffusion/sd-next/docker-entrypoint.sh create mode 100644 packages/diffusion/sd-next/docs.md diff --git a/packages/diffusion/sd-next/Dockerfile b/packages/diffusion/sd-next/Dockerfile new file mode 100644 index 000000000..9dee7e27b --- /dev/null +++ b/packages/diffusion/sd-next/Dockerfile @@ -0,0 +1,38 @@ +#--- +# name: sd-next +# group: diffusion +# depends: [python, pycuda, protobuf:apt, numba, numpy, tensorflow2, opencv, pytorch, torchvision, transformers, xformers, huggingface_hub] +# requires: '>=34.1.0' +# docs: docs.md +# notes: disabled on JetPack 4 +#--- +ARG BASE_IMAGE +FROM ${BASE_IMAGE} + +ARG SD_NEXT_REPO=vladmandic/automatic +ARG SD_NEXT_VERSION=master + +ADD https://api.github.com/repos/${SD_NEXT_REPO}/git/refs/heads/${SD_NEXT_VERSION} /tmp/sd_next_version.json + +RUN cd /opt && \ + git clone --branch ${SD_NEXT_VERSION} --depth=1 https://github.com/${SD_NEXT_REPO} && \ + cd automatic && \ + sed 's|^huggingface_hub.*||' -i requirements.txt && \ + sed 's|^transformers.*||' -i requirements.txt && \ + sed 's|^protobuf.*||' -i requirements.txt && \ + sed 's|^numba.*||' -i requirements.txt && \ + sed 's|^numpy.*||' -i requirements.txt && \ + cat requirements.txt && \ + TENSORFLOW_PACKAGE=https://nvidia.box.com/shared/static/wp43cd8e0lgen2wdqic3irdwagpgn0iz.whl python3 ./launch.py --skip-torch --use-cuda --reinstall --test + +# partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline' +RUN cd /opt && ./opencv_install.sh + +# set the cache dir for models +ENV DIFFUSERS_CACHE=/data/models/diffusers + +COPY docker-entrypoint.sh /usr/local/bin + +WORKDIR /opt/automatic + +ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/packages/diffusion/sd-next/README.md b/packages/diffusion/sd-next/README.md new file mode 100644 index 000000000..fee452477 --- /dev/null +++ b/packages/diffusion/sd-next/README.md @@ -0,0 +1,110 @@ +# sd-next + +> [`CONTAINERS`](#user-content-containers) [`IMAGES`](#user-content-images) [`RUN`](#user-content-run) [`BUILD`](#user-content-build) + + + + +* SD.Next from https://github.com/vladmandic/automatic (found under `/opt/automatic`) +* with TensorRT extension from https://github.com/AUTOMATIC1111/stable-diffusion-webui-tensorrt +* see the tutorial at the [**Jetson Generative AI Lab**](https://nvidia-ai-iot.github.io/jetson-generative-ai-playground/tutorial_diffusion.html) + +This container has a default run command that will automatically start the webserver like this: + +```bash +cd /opt/automatic && python3 launch.py \ + --data=/data/models/stable-diffusion \ + --enable-insecure-extension-access \ + --xformers \ + --listen \ + --port=7860 +``` + +After starting the container, you can navigate your browser to `http://$IP_ADDRESS:7860` (substitute the address or hostname of your device). The server will automatically download the default model ([`stable-diffusion-1.5`](https://huggingface.co/runwayml/stable-diffusion-v1-5)) during startup. + +Other configuration arguments can be found at [AUTOMATIC1111/stable-diffusion-webui/wiki/Command-Line-Arguments-and-Settings](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Command-Line-Arguments-and-Settings) + +* `--medvram` (sacrifice some performance for low VRAM usage) +* `--lowvram` (sacrafice a lot of speed for very low VRAM usage) + +See the [`stable-diffusion`](/packages/diffusion/stable-diffusion) container to run image generation from a script (`txt2img.py`) as opposed to the web UI. + +### Tips & Tricks + +Negative prompts: https://huggingface.co/spaces/stabilityai/stable-diffusion/discussions/7857 + +Stable Diffusion XL + * https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/stable_diffusion_xl + * https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0 + * https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0 + * https://stable-diffusion-art.com/sdxl-model/ +
+CONTAINERS +
+ +| **`stable-diffusion-webui`** | | +| :-- | :-- | +|    Builds | [![`stable-diffusion-webui_jp51`](https://img.shields.io/github/actions/workflow/status/dusty-nv/jetson-containers/stable-diffusion-webui_jp51.yml?label=stable-diffusion-webui:jp51)](https://github.com/dusty-nv/jetson-containers/actions/workflows/stable-diffusion-webui_jp51.yml) [![`stable-diffusion-webui_jp60`](https://img.shields.io/github/actions/workflow/status/dusty-nv/jetson-containers/stable-diffusion-webui_jp60.yml?label=stable-diffusion-webui:jp60)](https://github.com/dusty-nv/jetson-containers/actions/workflows/stable-diffusion-webui_jp60.yml) | +|    Requires | `L4T >=34.1.0` | +|    Dependencies | [`build-essential`](/packages/build-essential) [`cuda`](/packages/cuda/cuda) [`cudnn`](/packages/cuda/cudnn) [`python`](/packages/python) [`tensorrt`](/packages/tensorrt) [`numpy`](/packages/numpy) [`cmake`](/packages/cmake/cmake_pip) [`onnx`](/packages/onnx) [`pytorch`](/packages/pytorch) [`torchvision`](/packages/pytorch/torchvision) [`huggingface_hub`](/packages/llm/huggingface_hub) [`rust`](/packages/rust) [`transformers`](/packages/llm/transformers) [`xformers`](/packages/llm/xformers) [`pycuda`](/packages/cuda/pycuda) [`opencv`](/packages/opencv) | +|    Dependants | [`l4t-diffusion`](/packages/l4t/l4t-diffusion) | +|    Dockerfile | [`Dockerfile`](Dockerfile) | +|    Images | [`dustynv/stable-diffusion-webui:r35.2.1`](https://hub.docker.com/r/dustynv/stable-diffusion-webui/tags) `(2023-12-05, 7.1GB)`
[`dustynv/stable-diffusion-webui:r35.3.1`](https://hub.docker.com/r/dustynv/stable-diffusion-webui/tags) `(2023-11-05, 7.1GB)`
[`dustynv/stable-diffusion-webui:r35.4.1`](https://hub.docker.com/r/dustynv/stable-diffusion-webui/tags) `(2023-11-05, 7.1GB)`
[`dustynv/stable-diffusion-webui:r36.2.0`](https://hub.docker.com/r/dustynv/stable-diffusion-webui/tags) `(2023-12-05, 8.8GB)` | +|    Notes | disabled on JetPack 4 | + +
+ +
+CONTAINER IMAGES +
+ +| Repository/Tag | Date | Arch | Size | +| :-- | :--: | :--: | :--: | +|   [`dustynv/stable-diffusion-webui:r35.2.1`](https://hub.docker.com/r/dustynv/stable-diffusion-webui/tags) | `2023-12-05` | `arm64` | `7.1GB` | +|   [`dustynv/stable-diffusion-webui:r35.3.1`](https://hub.docker.com/r/dustynv/stable-diffusion-webui/tags) | `2023-11-05` | `arm64` | `7.1GB` | +|   [`dustynv/stable-diffusion-webui:r35.4.1`](https://hub.docker.com/r/dustynv/stable-diffusion-webui/tags) | `2023-11-05` | `arm64` | `7.1GB` | +|   [`dustynv/stable-diffusion-webui:r36.2.0`](https://hub.docker.com/r/dustynv/stable-diffusion-webui/tags) | `2023-12-05` | `arm64` | `8.8GB` | + +> Container images are compatible with other minor versions of JetPack/L4T:
+>     • L4T R32.7 containers can run on other versions of L4T R32.7 (JetPack 4.6+)
+>     • L4T R35.x containers can run on other versions of L4T R35.x (JetPack 5.1+)
+
+ +
+RUN CONTAINER +
+ +To start the container, you can use the [`run.sh`](/docs/run.md)/[`autotag`](/docs/run.md#autotag) helpers or manually put together a [`docker run`](https://docs.docker.com/engine/reference/commandline/run/) command: +```bash +# automatically pull or build a compatible container image +./run.sh $(./autotag sd-next) + +# or explicitly specify one of the container images above +./run.sh dustynv/sd-next:r35.2.1 + +# or if using 'docker run' (specify image and mounts/ect) +sudo docker run --runtime nvidia -it --rm --network=host dustynv/sd-next:r35.2.1 +``` +> [`run.sh`](/docs/run.md) forwards arguments to [`docker run`](https://docs.docker.com/engine/reference/commandline/run/) with some defaults added (like `--runtime nvidia`, mounts a `/data` cache, and detects devices)
+> [`autotag`](/docs/run.md#autotag) finds a container image that's compatible with your version of JetPack/L4T - either locally, pulled from a registry, or by building it. + +To mount your own directories into the container, use the [`-v`](https://docs.docker.com/engine/reference/commandline/run/#volume) or [`--volume`](https://docs.docker.com/engine/reference/commandline/run/#volume) flags: +```bash +./run.sh -v /path/on/host:/path/in/container $(./autotag sd-next) +``` +To launch the container running a command, as opposed to an interactive shell: +```bash +./run.sh $(./autotag sd-next) my_app --abc xyz +``` +You can pass any options to [`run.sh`](/docs/run.md) that you would to [`docker run`](https://docs.docker.com/engine/reference/commandline/run/), and it'll print out the full command that it constructs before executing it. +
+
+BUILD CONTAINER +
+ +If you use [`autotag`](/docs/run.md#autotag) as shown above, it'll ask to build the container for you if needed. To manually build it, first do the [system setup](/docs/setup.md), then run: +```bash +./build.sh sd-next +``` +The dependencies from above will be built into the container, and it'll be tested during. See [`./build.sh --help`](/jetson_containers/build.py) for build options. +
diff --git a/packages/diffusion/sd-next/docker-entrypoint.sh b/packages/diffusion/sd-next/docker-entrypoint.sh new file mode 100755 index 000000000..c7f920d9e --- /dev/null +++ b/packages/diffusion/sd-next/docker-entrypoint.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -e + +cd /opt/automatic + +if [[ ! -z "${ACCELERATE}" ]] && [ ${ACCELERATE}="True" ] && [ -x "$(command -v accelerate)" ] +then + echo "Launching accelerate launch.py..." + exec accelerate launch --num_cpu_threads_per_process=6 launch.py --data=/data/models/stable-diffusion --skip-all --use-xformers --use-cuda --listen --port=7860 "$@" +else + echo "Launching launch.py..." + exec python3 launch.py --data=/data/models/stable-diffusion --skip-all --use-xformers --use-cuda --listen --port=7860 "$@" +fi diff --git a/packages/diffusion/sd-next/docs.md b/packages/diffusion/sd-next/docs.md new file mode 100644 index 000000000..c76bbc383 --- /dev/null +++ b/packages/diffusion/sd-next/docs.md @@ -0,0 +1,36 @@ + + + +* stable-diffusion-webui from https://github.com/AUTOMATIC1111/stable-diffusion-webui (found under `/opt/stable-diffusion-webui`) +* with TensorRT extension from https://github.com/AUTOMATIC1111/stable-diffusion-webui-tensorrt +* see the tutorial at the [**Jetson Generative AI Lab**](https://nvidia-ai-iot.github.io/jetson-generative-ai-playground/tutorial_diffusion.html) + +This container has a default run command that will automatically start the webserver like this: + +```bash +cd /opt/stable-diffusion-webui && python3 launch.py \ + --data=/data/models/stable-diffusion \ + --enable-insecure-extension-access \ + --xformers \ + --listen \ + --port=7860 +``` + +After starting the container, you can navigate your browser to `http://$IP_ADDRESS:7860` (substitute the address or hostname of your device). The server will automatically download the default model ([`stable-diffusion-1.5`](https://huggingface.co/runwayml/stable-diffusion-v1-5)) during startup. + +Other configuration arguments can be found at [AUTOMATIC1111/stable-diffusion-webui/wiki/Command-Line-Arguments-and-Settings](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Command-Line-Arguments-and-Settings) + +* `--medvram` (sacrifice some performance for low VRAM usage) +* `--lowvram` (sacrafice a lot of speed for very low VRAM usage) + +See the [`stable-diffusion`](/packages/diffusion/stable-diffusion) container to run image generation from a script (`txt2img.py`) as opposed to the web UI. + +### Tips & Tricks + +Negative prompts: https://huggingface.co/spaces/stabilityai/stable-diffusion/discussions/7857 + +Stable Diffusion XL + * https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/stable_diffusion_xl + * https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0 + * https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0 + * https://stable-diffusion-art.com/sdxl-model/ \ No newline at end of file