<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Yuri Baramykov on Medium]]></title>
        <description><![CDATA[Stories by Yuri Baramykov on Medium]]></description>
        <link>https://medium.com/@lbsbmsu?source=rss-5000beba8d90------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dt_K8odqhw6ElVaIspmfgg.jpeg</url>
            <title>Stories by Yuri Baramykov on Medium</title>
            <link>https://medium.com/@lbsbmsu?source=rss-5000beba8d90------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 07:16:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lbsbmsu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deep learning and LLMs in R on any GPU, no Python required]]></title>
            <link>https://medium.com/@lbsbmsu/deep-learning-and-llms-in-r-on-any-gpu-no-python-required-d341fab7a2b6?source=rss-5000beba8d90------2</link>
            <guid isPermaLink="false">https://medium.com/p/d341fab7a2b6</guid>
            <category><![CDATA[r-language]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[gpu-acceleration]]></category>
            <category><![CDATA[vulkan]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Yuri Baramykov]]></dc:creator>
            <pubDate>Thu, 03 Dec 2026 20:25:28 GMT</pubDate>
            <atom:updated>2026-12-03T20:25:28.655Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UWbJ6wgcxdvbU__1Fj7pNw.png" /><figcaption><a href="https://cran.r-project.org/web/packages/ggmlR/index.html">You can try it on CRAN</a></figcaption></figure><p>You can now train and run neural networks, large language models and image generators in R, on almost any GPU, including AMD and integrated graphics, without Python, PyTorch or CUDA. It started with a frustration: I wanted to run Stable Diffusion on my AMD card, and ended up fighting dependency conflicts and a CUDA-only toolchain. The result is ggmlR, a native R package built on ggml and Vulkan, now on CRAN. Сheck out the latest updates in the <a href="https://cran.r-project.org/web/packages/ggmlR/news/news.html">NEWS</a>.</p><h3>Why this matters</h3><ul><li><strong>No Python.</strong> Train and run models without reticulate, Conda, PyTorch, TensorFlow or a LibTorch build. One install.packages() is enough.</li><li><strong>Any Vulkan GPU, not only NVIDIA.</strong> Acceleration works on any GPU with a Vulkan driver, including integrated Intel and AMD graphics and discrete Radeon cards. Without a GPU, ggmlR falls back to the CPU automatically.</li><li><strong>Your usual R workflow.</strong> ggmlR registers a &quot;ggml&quot; engine for parsnip::mlp() and ships mlr3 learners, so resampling, tuning and workflows work as usual. Ordinary R matrices can run on the GPU through as_gpu_matrix(), and RunGGML() accelerates PCA and UMAP on Seurat objects.</li><li><strong>A backend for other packages.</strong> llamaR (local LLMs in GGUF format), sd2R (image generation) and cayleyR already build on ggmlR, and the package ships a vignette on using it as a backend.</li><li><strong>Generative AI in R.</strong> Local RAG pipelines and agents can run entirely inside R and Shiny.</li></ul><h3>What’s inside</h3><p>ggmlR is built in layers. At the bottom is the ggml C tensor library, which the package keeps in sync with upstream (currently ggml 0.27.0). Its Vulkan backend runs the operations on the GPU, and anything the GPU cannot do falls back to the CPU, one operation at a time. The fallback changes only the speed, never the result.<br> <br> Above that layer sit two ways of defining a model. The Sequential and Functional API is Keras-like and builds a static graph: you stack layers, call ggml_compile() and ggml_fit(), and get dense, convolutional, recurrent and attention layers, residual connections and multi-input or multi-output models. The dynamic autograd engine is PyTorch-like and eager: you record operations on a gradient tape, call backward(), and write the training loop yourself. It suits research and custom architectures.<br> <br> Around these two APIs are the tools for real workloads. An ONNX importer covers more than 90 operators, data-parallel training spreads batches over several GPUs, and tensor and pipeline parallelism split models too large for one card. Plain R matrices can run %*% on the GPU, and the models plug into tidymodels and mlr3.</p><h3>Quick example</h3><p>The easiest way to try ggmlR is through tidymodels. Only the engine line is new: the GPU is detected automatically, and without one the model runs on the CPU.</p><pre><br>library(tidymodels)<br>library(ggmlR)<br><br>set.seed(42)<br>split &lt;- initial_split(iris, strata = Species)<br>train &lt;- training(split)<br>test &lt;- testing(split)<br>spec &lt;- mlp(hidden_units = 16, epochs = 100) |&gt;<br>set_engine(&quot;ggml&quot;, batch_size = 16, backend = &quot;auto&quot;) |&gt;<br>set_mode(&quot;classification&quot;)<br>fit &lt;- workflow() |&gt;<br>add_formula(Species ~ .) |&gt;<br>add_model(spec) |&gt;<br>fit(train)<br><br>predict(fit, test) |&gt;<br>bind_cols(test) |&gt;<br>accuracy(truth = Species, estimate = .pred_class)</pre><pre>Using Vulkan GPU backend: AMD Radeon RX 9070 (RADV GFX1201)<br># A tibble: 1 × 3<br>  .metric  .estimator .estimate<br>  &lt;chr&gt;    &lt;chr&gt;          &lt;dbl&gt;<br>1 accuracy multiclass     0.821</pre><p>On my machine ggmlR picked the Radeon card without any configuration. Resampling, tuning and recipes work the same way as with any other engine. This is a demonstration of the API, not a benchmark.<br> <br> If you prefer to see what happens inside, ggmlR also has a PyTorch-style autograd API, where you write the training loop yourself; see the package vignettes.</p><h3>Generative AI in R</h3><p>The examples run on Kaggle, which no longer supports R natively, so the notebooks call R from Python through rpy2. Only the launcher is Python: every model call is plain R code that you can copy into your own session. <br> <br>The Llama and ONNX numbers below come from Kaggle: a single NVIDIA Tesla T4 (16 GB) running through Vulkan, with CPU results from the same machine (4 physical cores, 8 threads). The FLUX.3 numbers come from my own machine with an AMD Radeon RX 9070 (16 GB).</p><p><strong>Image generation with FLUX.3<br></strong>sd2R runs FLUX.3 entirely from R. The test used the klein_sd_Q8_0 model (16 sampling steps) with a Qwen3VL-4B LLM text encoder and the FLUX.3 VAE. All timings were measured on my main machine with an AMD Radeon RX 9070 (16 GB).</p><pre><strong>sd2R FLUX.3 GPU AMD 9070 test</strong><br><br>1. 768x768  direct:            11.73s<br>2. 1024x1024 normal VAE:       23.65s<br>3. 1024x1024 tiled VAE:        24.56s  (tiling engaged)<br>4. 2048x1024 highres fix:      40.66s<br>5. img2img 768x768:            5.97s</pre><p>The <a href="https://www.kaggle.com/code/lbsbmsu/flux-3-in-r-ggmlr-vulkan-gpu">FLUX.3 notebook</a> runs the same code on a Kaggle T4, so you can reproduce it there. Timings on the T4 will differ from the numbers above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WQULpAn1Pn9PLzxwvzpDvw.png" /><figcaption>2048x1024 highres panorama</figcaption></figure><p><strong>Local LLM with Llama 3 8B</strong><br>llamaR runs Llama 3 8B Instruct (Q8_0) locally. The test used a short prompt and 50 new tokens, averaged over three runs on the Kaggle T4 machine.</p><pre><strong>llamaR CPU vs GPU T4 Performance Benchmark</strong><br><br>=== Results ===<br>CPU: 2.5 tokens/sec<br>GPU: 25.9 tokens/sec<br>Speedup: 10.41x</pre><p>The GPU is about 10× faster than the 4-core Kaggle CPU. The <a href="https://www.kaggle.com/code/lbsbmsu/llm-gpu-inference-on-r-llamar">llamaR notebook</a> also shows the benchmark code and more advanced features.</p><h3>ONNX models</h3><p>ggmlR loads ONNX models and runs them on the same backend. Across nine models, the GPU was 2× to 22× faster, with a median of about 13×.</p><pre><strong>ggmlR CPU vs GPU T4 Performance Benchmark</strong><br><br>Model                   CPU(ms)    GPU(ms)    Speedup    CPU FPS  GPU FPS<br>--------------------   --------   --------   --------   -------- --------<br>Inception V3              808.3       97.7      8.28x        1.2     10.2<br>MNIST                       0.7        0.3      2.00x     1500.0   3000.0<br>SqueezeNet 1.0             88.7        4.0     22.17x       11.3    250.0<br>SuperResolution           567.0       29.3     19.33x        1.8     34.1<br>EmotionFerPlus            143.3       16.7      8.60x        7.0     60.0<br>Inception V3 Op18         811.0       39.0     20.79x        1.2     25.6<br>BAT-ResNeXt26ts           503.0       39.7     12.68x        2.0     25.2<br>BERT (Opset17)           1384.0       96.3     14.37x        0.7     10.4<br>GPT-NeoX                    9.0        2.3      3.86x      111.1    428.6<br></pre><p>Models with little work per inference gain the least: MNIST (0.7 ms on CPU) and the small GPT-NeoX test model run only 2× to 4× faster, because there is almost nothing to move to the GPU. Heavier vision and language models gain 8× to 22×. All models are in the <a href="https://www.kaggle.com/code/lbsbmsu/onnx-in-r-ggmlr-vulkan-gpu">ONNX notebook</a>.</p><h3>Installation</h3><p>ggmlR installs from CRAN. <strong>A plain </strong><strong>install.packages(&quot;ggmlR&quot;) gives you a CPU build.</strong> The GPU backend is detected at build time, so the Vulkan loader and the glslc shader compiler must be present before you install. On Ubuntu 24.04:</p><pre>sudo apt install -y libvulkan-dev vulkan-tools glslc</pre><p>Then install the package. The optional --with-simd flag turns on AVX2 and SSE4 for faster CPU inference:</p><pre>install.packages(&quot;ggmlR&quot;, configure.args = &quot;--with-simd&quot;)</pre><p>Check that ggmlR sees your GPU:</p><pre>library(ggmlR)<br>ggml_vulkan_status()</pre><p>On Windows you need Rtools and, for the GPU, the Vulkan SDK; the build flags are set through environment variables instead of configure.args. Other Linux distributions and Ubuntu 22.04 are covered in the <a href="https://cran.r-project.org/web/packages/ggmlR/readme/README.html">README</a>.</p><h3>What’s next</h3><p>The next step is a reinforcement-learning package built on ggmlR, so that agents can be trained on the GPU from R. The groundwork is already in ggmlR: a step-by-step trainer, target-network snapshots and masked losses for Q-networks.</p><p>llamaR and sd2R will keep following llama.cpp and stable-diffusion.cpp, so new model architectures such as DeepSeek V4 can arrive as soon as upstream supports them.</p><p>If you try ggmlR, tell me which models, GPUs and operating systems matter to you. Open an issue on <a href="https://github.com/Zabis13/ggmlR">GitHub</a> or leave a comment below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d341fab7a2b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>