File tree Expand file tree Collapse file tree 6 files changed +122
-0
lines changed
Expand file tree Collapse file tree 6 files changed +122
-0
lines changed Original file line number Diff line number Diff line change 1+ ARG BASE_IMAGE=temurin-21-tools-deps-jammy
2+ FROM clojure:${BASE_IMAGE}
3+
4+ ARG USERNAME=vscode
5+ ARG USER_UID=1001
6+ ARG USER_GID=$USER_UID
7+
8+ # Create the user
9+ RUN groupadd --gid $USER_GID $USERNAME \
10+ && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
11+ #
12+ # [Optional] Add sudo support. Omit if you don't need to install software after connecting.
13+ && apt-get update \
14+ && apt-get install -y sudo \
15+ && echo $USERNAME ALL=\( root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
16+ && chmod 0440 /etc/sudoers.d/$USERNAME
17+
18+
19+ # [Optional] Set the default user. Omit if you want to keep the default as root.
20+ USER $USERNAME
21+ SHELL ["/bin/bash" , "-ec" ]
22+ ENTRYPOINT ["bash" ]
23+
24+
25+ # Prepare clojure tools
26+ RUN clojure -Ttools list && \
27+ clojure -Ttools install io.github.seancorfield/clj-new '{:git/tag "v1.2.404" :git/sha "d4a6508"}' :as clj-new && \
28+ clojure -Ttools install-latest :lib io.github.seancorfield/deps-new :as new && \
29+ clojure -Ttools install io.github.zmedelis/hfds-clj '{:git/url "https://github.com/zmedelis/hfds-clj" :git/sha "4a84254030fceca8bf3f5e8dce4226b4b8cdf48a"}' :as hfds-clj && \
30+ clojure -Ttools list
31+
32+ RUN sudo apt-get update && \
33+ sudo apt-get install -y lsb-release wget
34+
Original file line number Diff line number Diff line change 1+ #! /bin/bash -ex
2+ # wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
3+ # sudo dpkg -i cuda-keyring_1.1-1_all.deb
4+ # wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-ubuntu2404.pin
5+ # sudo mv cuda-ubuntu2404.pin /etc/apt/preferences.d/cuda-repository-pin-600
6+ # sudo apt-get update
7+ # sudo apt-get install -y cuda-toolkit-12 cudnn9-cuda-12
8+ apt-get update
9+ apt-get install -y cmake python3.12-dev python3.12-venv build-essential
10+ cd /root
11+ git clone https://github.com/microsoft/onnxruntime-genai
12+ cd /root/onnxruntime-genai
13+ git checkout v0.11.2
14+ python3 -m venv .venv
15+ source .venv/bin/activate
16+ pip install requests
17+ export CUDA_HOME=/usr/local/cuda
18+ python build.py --use_cuda --build_java --config Release --publish_java_maven_local
19+ cp /root/onnxruntime-genai/src/java/build/libs/onnxruntime-genai-0.11.2.jar /tmp/
20+ mkdir /tmp/onnxruntime-genai.native
21+ cp /root/onnxruntime-genai/build/Linux/Release/* .so /tmp/onnxruntime-genai.native
22+ cp /root/onnxruntime-genai/build/Linux/Release/src/java/libonnxruntime-genai-jni.so /tmp/onnxruntime-genai.native/
Original file line number Diff line number Diff line change 1+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+ // README at: https://github.com/scicloj/devcontainer-templates/tree/main/src/basecloj
3+ {
4+ "name" : " onnx-genai tutorial" ,
5+ "build" : {
6+ "dockerfile" : " Dockerfile" ,
7+ "args" : {
8+ "BASE_IMAGE" : " temurin-21-tools-deps-noble" ,
9+ "USERNAME" : " ${localEnv:USER:vscode}"
10+ }
11+ },
12+
13+ "runArgs" :
14+ [
15+ // "--device", "nvidia.com/gpu=all" // working on nixos
16+ " --runtime=nvidia" , " --gpus" , " all" // working in codevm
17+ ],
18+
19+ "remoteUser" : " ${localEnv:USER}" ,
20+ "containerUser" : " ${localEnv:USER}" ,
21+ "features" : {
22+ "ghcr.io/devcontainers/features/git:1" : {
23+ "ppa" : true ,
24+ "version" : " os-provided"
25+ },
26+ "ghcr.io/rocker-org/devcontainer-features/quarto-cli:1" : {
27+ "version" : " latest"
28+ },
29+ "ghcr.io/devcontainers/features/nvidia-cuda:2" : {
30+ "installCudnn" : true ,
31+ "cudaVersion" : " 12.9" ,
32+ "installToolkit" : true ,
33+ "cudnnVersion" : " automatic"
34+ }
35+ },
36+ "customizations" : {
37+ "vscode" : {
38+ "extensions" : [
39+ " betterthantomorrow.calva"
40+ ]
41+ }
42+ },
43+ "onCreateCommand" : " sudo .devcontainer/buildGenAi.sh" ,
44+ "postCreateCommand" : " .devcontainer/loadModels.sh"
45+
46+
47+ }
Original file line number Diff line number Diff line change 1+ #! /bin/bash -ex
2+ clojure -Thfds-clj hfds-clj.models/download-cli :model ' "microsoft/Phi-3-mini-4k-instruct-onnx"' :hf-token " <token>" :models-base-dir ' "/tmp/models"'
Original file line number Diff line number Diff line change 1+ {
2+ ; the devcontainer setup build and puts the jar and native libs in the below places
3+ :deps { onnxruntime/genai {:local/root " /tmp/onnxruntime-genai-0.11.2.jar" }}
4+ :aliases {:linux {:jvm-opts [" -Donnxruntime-genai.native.path=/tmp/onnxruntime-genai.native" ]}}
5+ }
Original file line number Diff line number Diff line change 1+ (ns generate
2+ (:import [ai.onnxruntime.genai SimpleGenAI]))
3+
4+ ; ; model is loaded by devcontaier setup
5+ (def gen-ai (SimpleGenAI. " /tmp/models/microsoft/Phi-3-mini-4k-instruct-onnx/cuda/cuda-fp16/" ))
6+ (def gen-params (.createGeneratorParams gen-ai))
7+ (.generate gen-ai
8+ gen-params
9+ " What is onnxruntime-genai ?"
10+ ^java.util.function.Consumer (fn [s] (print s)))
11+
12+
You can’t perform that action at this time.
0 commit comments