-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't get inference running on GPU #9
Comments
Hi @TonsOfFun, I think it's a bug with this library, but not sure when I'll be able to work on it. It looks like |
That's kinda what I was thinking thanks for the suggestion. I'll see if I can get something working and open a PR. Also gonna try loading this PyTorch model with torch.rb. It looks like the CUDA support might be more readily available there. I'll report back here either way. |
Hey @TonsOfFun, fixed in the commit above if you pass |
This is awesome! I've been traveling, but I'll test it out tomorrow. |
I did some testing and keep running into an error. I have tried a couple ways with
or putting the contents into:
OnnxRuntime.ffi_lib = "/var/lib/gems/3.0.0/bundler/gems/onnxruntime-ruby-abf11244043e/vendor/libonnxruntime.so.1.15.1" Either way I seem to get this error: model = OnnxRuntime::Model.new("yolov8n.onnx", providers: ["CUDAExecutionProvider"])
I'm running this all on an image based on |
It looks like the pre-built GPU version uses CUDA 11, so you'll need to either use that or try to compile it from source with CUDA 12. |
That was it! I ended up using a modified version of the ml-stack image: FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
ENV RUBY_VERSION 3.1.2
# install packages
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y --no-install-recommends \
autoconf \
automake \
build-essential \
imagemagick \
libczmq-dev \
libffi-dev \
libreadline-dev \
libsox-dev \
libsox-fmt-all \
libssl-dev \
libtool \
libvips \
libyaml-dev \
libzmq3-dev \
make \
python3 \
python3-pip \
python3-setuptools \
sox \
unzip \
wget \
git \
zlib1g-dev \
&& \
rm -rf /var/lib/apt/lists/*
# install Ruby
RUN cd /tmp && \
wget -O ruby.tar.gz -q https://cache.ruby-lang.org/pub/ruby/3.1/ruby-$RUBY_VERSION.tar.gz && \
mkdir ruby && \
tar xfz ruby.tar.gz -C ruby --strip-components=1 && \
rm ruby.tar.gz && \
cd ruby && \
./configure --disable-install-doc --enable-shared && \
make -j && \
make install && \
cd .. && \
rm -r ruby && \
ruby --version && \
bundle --version
# install Jupyter
RUN pip3 install jupyter && \
jupyter kernelspec remove -f python3 && \
mkdir /root/.jupyter && \
echo 'c.KernelSpecManager.ensure_native_kernel = False' > ~/.jupyter/jupyter_notebook_config.py
# install LibTorch
RUN cd /opt && \
wget -O libtorch.zip -q https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.12.0%2Bcu113.zip && \
unzip -q libtorch.zip && \
rm libtorch.zip
RUN gem install \
ffi-rzmq \
iruby \
mini_magick \
numo-narray && \
iruby register
WORKDIR /app
RUN bundle install
# COPY torch-gpu/MNIST.ipynb ./
CMD ["jupyter", "notebook", "--no-browser", "--ip=0.0.0.0", "--allow-root"] With this Gemfile: source "https://rubygems.org"
gem "numo-narray", platform: [:ruby, :x64_mingw]
# until released 0.7.8 is released with GPU support
gem "onnxruntime", git: 'https://github.com/ankane/onnxruntime-ruby.git', ref: 'abf1124'
gem "mini_magick" In case it's helpful to you or someone else. Thanks again for the support here! |
First off, great work! I have loaded the
yolov8n.onnx
model from ultralytics and it runs on CPU no problem.When attempting to run on my GPU I can see the CUDAExecutionProvider is available, but
=> ["TensorrtExecutionProvider", "CUDAExecutionProvider", "CPUExecutionProvider"]
but when I run predictions it's only using the CPU
The text was updated successfully, but these errors were encountered: