TGViewer
Data eXplore : Data Science, ML, Big Data, LLMs and AI Security Data eXplore : Data Science, ML, Big Data, LLMs and AI Security @dataxplore · 583 subscribers
Post #1884 181
Your container doesn't contain GPU drivers at all then,

🟢 How does PyTorch inside it use the host's GPU?

You need to understand what is happening on the host side
The NVIDIA driver in the kernel provides GPU access through device files: /dev/nvidia0, /dev/nvidiactl, and so on

Any application communicates with the GPU exactly through these device files

PyTorch does not directly access the driver
It works through CUDA Runtime (libcudart.so) which is a high-level API that handles allocations, kernel launches, and synchronization

This runtime library is inside your container

The entire stack looks like this:
PyTorch → CUDA Runtime → CUDA Driver → /dev/nvidia0 → kernel → GPU

Runtime lives in the container
Driver lives on the host


🔵 How do they connect?

Look at the container launch:
Containerd → containerd-shim → OCI-runtime (runc) → container

But if the driver is on the host and the runtime is in the container, how does the application access everything at once?

Answer: OCI hooks

The OCI specification defines hooks (code) that runs at different stages of the container's lifecycle:

prestart/createRuntime
createContainer
startContainer
poststart
poststop

NVIDIA uses these hooks to add GPU support

Before the container starts, the hook does the following:

1. Mounts GPU devices (/dev/nvidia*)
2. Places driver libraries from the host into the container
3. Sets the necessary environment variables
4. Configures device cgroups

Your application has not even started yet

All of this is handled by NVIDIA Container Toolkit. It intercepts container creation and carefully inserts everything needed for GPU operation

Your image remains normal.
GPU capabilities appear at runtime.


••••••••••••••••••••••••••••••••••••
🤖 Data Science, ML & Big Data with @DataXplore
More from @dataxplore
  1. Oct 1, 2026Monitoring and debugging "silent" token drift in LLM pipelines: frequency analysis of embe…
  2. Sep 30, 2026Online detection of feature collisions in TDA transformation When using Topological Data A…
  3. Sep 18, 2026Am going to announce something big (for me, it's really big) on October 11, 2026.
  4. Sep 14, 2026Post #2188
  5. Aug 31, 2026I joined a Russian community on Telegram. They share some Russian startup and technology u…
  6. Aug 22, 2026Post #2185
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →