21 Commits
Author SHA1 Message Date
Ayush RanjanandgVisor bot 138e98fb7d nvproxy: Refactor DriverVersion out to nvconf package.
This allows for runsc to be able to use DriverVersion without having to depend
on the entirety of nvproxy.

PiperOrigin-RevId: 733912696
2025-03-05 16:43:03 -08:00
Etienne PerotandgVisor bot 004ed53163 nvproxy: Do capability-based segmentation for seccomp filters.
Updates #10856

PiperOrigin-RevId: 698599198
2024-11-20 18:54:57 -08:00
Etienne PerotandgVisor bot 6953ca0ca3 Add NVIDIA driver capability segmentation support to nvproxy.
This wraps `nvproxy`'s `ioctl` handlers with wrappers that are
driver-capability-aware, and initially populates the ABI tree
with all functions marked as being available for capabilities
`compute` and `utility`.

It is not yet possible for the user to specify which capability
they want to enable. This should not cause a regression for users
because the hardcoded effective capability set is the one that is
currently specified for all current handlers.

Updates #9452.
Updates #10856.

PiperOrigin-RevId: 697824737
2024-11-18 18:15:21 -08:00
Zach KoopmansandgVisor bot 23c8b4b042 Add test to check COS drivers as they are posted.
Our current check of COS drivers often lags behind COS releases.
This is due to needing to preload GPU docker images onto the
images that run in our CI pipelines.

In addition, COS can be a bit more complex than originally thought
releasing driver versions both across GPU types and release branches.

Thus, this test searches the latest COS images on each family for
new drivers. It does this by looking at COS's published release notes
which include a proto of LATEST/DEFAULT drivers selected for each device.

This will flag new versions faster with more coverage than our
CI pipeline currently. Due to this not actually needing a GPU
to run, this can run on any VM.

PiperOrigin-RevId: 693736100
2024-11-06 08:30:38 -08:00
Jamie LiuandgVisor bot 1f4299ee3f nvproxy: implement frontendFDMemmapFile.MapInternal()
New test, before this CL:

```
Testing read/write syscalls on cudaMallocHost memory
cuda_malloc: write: Bad address
```

After this CL:

```
Testing read/write syscalls on cudaMallocHost memory
Testing cudaMallocManaged(flags=cudaMemAttachGlobal)
Testing cudaMallocManaged(flags=cudaMemAttachGlobal) with prefetching
Testing cudaMallocManaged(flags=cudaMemAttachHost)
Testing cudaMallocManaged(flags=cudaMemAttachHost) with prefetching
Testing read/write syscalls on cudaMallocManaged memory
All tests passed
```

Fixes #10879

PiperOrigin-RevId: 672721411
2024-09-09 16:58:47 -07:00
Anthony CuiandgVisor bot 4f594794b8 Add nvproxy test to verify struct definitions using nvidia differ tool.
PiperOrigin-RevId: 662212161
2024-08-12 13:47:22 -07:00
Anthony CuiandgVisor bot 5017b6afc5 Add nvproxy test verifying that ABI struct names exist in the source code.
PiperOrigin-RevId: 657773809
2024-07-30 16:46:30 -07:00
Jamie LiuandgVisor bot 8db16e8859 nvproxy: try to propagate nvidia_poll()'s dataless_event_pending
See new comment in nvproxy.frontendFD for context.

PiperOrigin-RevId: 656524586
2024-07-26 14:15:28 -07:00
Anthony CuiandgVisor bot e8ca88e167 Add ioctl sniffing tool to run GPU workloads and report unsupported ioctl calls.
PiperOrigin-RevId: 644197930
2024-06-17 18:32:27 -07:00
Jamie LiuandgVisor bot d08e4a850b Internal change
PiperOrigin-RevId: 631677570
2024-05-08 00:09:42 -07:00
Jamie LiuandgVisor bot 434c4d2536 nvproxy: move save_restore.go to save_restore_impl.go
PiperOrigin-RevId: 631545504
2024-05-07 14:17:40 -07:00
Jamie LiuandgVisor bot 1e1334e88f nvproxy: track driver object dependencies
This is necessary to prevent osDescMem pinned page leaks when the osDescMem is
freed indirectly, e.g. by closing the `/dev/nvidiactl` FD that owns the
containing client.

- Switch from passing separate sentryIoctlParams to temporarily modifying
  ioctlParams in-place, in order to ensure that callers of *Invoke functions
  always observe ioctlParams updated by driver copy-out (including e.g. updated
  handles).

- Only pass NVOS64Parameters (rather than NVOS21Parameters) in NV_ESC_RM_ALLOC
  calls to the driver; this should behave equivalently (new comment in
  rmAllocInvoke()) and simplifies passing them to object registration callbacks
  (objAddLocked).

PiperOrigin-RevId: 627630863
2024-04-24 00:21:16 -07:00
Ayush RanjanandgVisor bot 09f56c1f1e Deprecate nvproxy support for driver versions <535.104.05.
See policy in https://gvisor.dev/docs/user_guide/gpu/#driver-versions.

PiperOrigin-RevId: 615557658
2024-03-13 15:13:30 -07:00
Jing ChenandgVisor bot be48200c0e Re-order loads in BUILD files to make transformations reversible in Copybara.
PiperOrigin-RevId: 598898756
2024-01-16 11:21:40 -08:00
Ayush RanjanandgVisor bot a5e93550c1 Move GPU device ownership to gofer process.
Tested on a T4 GPU with driver version 525.60.13:
```
$ docker run --runtime=runsc --gpus=all --rm -it nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubi8
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done
```

Also tested this on GKE with the same vectoradd workload. Checked that the
device gofer connection is actually being closed when the container is deleted.
Something to note is that the gofer logs for the GPU-container sometimes end
abruptly (the "All lisafs servers exited." line does not print). This is
because runsc/container/container.go:stop() SIGKILLs the gofer before it can
cleanup naturally. The device gofer connection is only closed at the end of
Loader.destroySubcontainer(), which gives little time before the gofer is
SIGKILL-ed.

PiperOrigin-RevId: 581365665
2023-11-10 14:20:31 -08:00
Ayush RanjanandgVisor bot 999c708319 Add support for restoring nvproxy.driverABI.
Fixes #9649

PiperOrigin-RevId: 580251470
2023-11-07 11:47:59 -08:00
Ayush RanjanandgVisor bot 9e66f710de Delete devtmpfs and replace it with tmpfs.
Our devtmpfs implementation uses the same tmpfs filesystem instance for all
devtmpfs mounts in the sandbox. This would mean that devices mounted in a
container are visible and accessible to all other containers in the sandbox.

With GPU/TPU, the contents of devtmpfs can be different for different
containers within the same sandbox. So it is important to not share the same
devtmpfs contents.

It is better to drop support for devtmpfs, than to implement it incorrectly.
Instead, this change introduces a new dummy filesystem type named `dev`. This
filesystem can not be mounted or listed by the application. This filesystem
creates a new tmpfs instance on GetFilesystem() and populates it with all the
device files.

PiperOrigin-RevId: 578969556
2023-11-02 13:58:58 -07:00
Zach KoopmansandgVisor bot d6e83e2802 Add nvidia installer tool for installing NVIDIA drivers in buildkite tests.
PiperOrigin-RevId: 574371646
2023-10-17 23:20:17 -07:00
Ayush RanjanandgVisor bot 584791a1f0 Add support for Nvidia driver versions after 535.43.02.
Nvproxy now supports 535.54.03 and 535.104.05 versions.
Tested on T4 GPU for these versions.
```
$ docker run --runtime=runsc --rm --gpus=all nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubi8
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done
```

PiperOrigin-RevId: 572312006
2023-10-10 11:18:34 -07:00
cce5b85235 Add driver versioning support in nvproxy.
This adds utilities to make it easier to add versioning support in nvproxy.
This way we can have different handling of ioctls based on driver versions.

The largest downside of this solution is the usage of maps instead of switch
statements. Switch statements are *way* faster than map accesses. The rationale
is that most of the latency bound work happens on the GPU for GPU workloads. So
micro-optimizations like using switch statements should not be visible.

Co-authored-by: Jamie Liu <jamieliu@google.com>
PiperOrigin-RevId: 570889581
2023-10-04 20:33:43 -07:00
Jamie LiuandgVisor bot 8c789fee2d Add //pkg/sentry/devices/nvproxy and //pkg/abi/nvgpu.
Currently, version 525.60.13 of the open-source driver is required; each driver
version needs to be individually qualified since the kernel driver's ABI is
unstable.

In conjunction with cl/529511919, on T4, A100, or L4 GPUs:

```
$ sudo docker run --gpus all --runtime=runsc nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubi8
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done

$ sudo docker run --gpus all --runtime=runsc -it nvcr.io/nvidia/pytorch:23.04-py3
...
root@ca01b7709883:/workspace# cd examples/upstream/word_language_model/ # see https://github.com/pytorch/examples/tree/main/word_language_model
root@ca01b7709883:/workspace/examples/upstream/word_language_model# python main.py --cuda --epochs 6 --model Transformer --lr 5
| epoch   1 |   200/ 2983 batches | lr 5.00 | ms/batch 10.52 | loss  7.60 | ppl  2003.10
| epoch   1 |   400/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  6.80 | ppl   895.15
| epoch   1 |   600/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  6.50 | ppl   664.17
| epoch   1 |   800/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  6.36 | ppl   576.66
| epoch   1 |  1000/ 2983 batches | lr 5.00 | ms/batch  5.61 | loss  6.26 | ppl   522.67
| epoch   1 |  1200/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  6.22 | ppl   504.51
| epoch   1 |  1400/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  6.15 | ppl   466.58
| epoch   1 |  1600/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  6.15 | ppl   470.48
| epoch   1 |  1800/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  6.03 | ppl   415.41
| epoch   1 |  2000/ 2983 batches | lr 5.00 | ms/batch  5.72 | loss  6.02 | ppl   412.43
| epoch   1 |  2200/ 2983 batches | lr 5.00 | ms/batch  5.93 | loss  5.93 | ppl   374.53
| epoch   1 |  2400/ 2983 batches | lr 5.00 | ms/batch  5.80 | loss  5.93 | ppl   377.23
| epoch   1 |  2600/ 2983 batches | lr 5.00 | ms/batch  5.74 | loss  5.93 | ppl   375.84
| epoch   1 |  2800/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  5.84 | ppl   343.92
-----------------------------------------------------------------------------------------
| end of epoch   1 | time: 19.08s | valid loss  5.75 | valid ppl   313.70
-----------------------------------------------------------------------------------------
| epoch   2 |   200/ 2983 batches | lr 5.00 | ms/batch  5.61 | loss  5.80 | ppl   329.43
| epoch   2 |   400/ 2983 batches | lr 5.00 | ms/batch  5.67 | loss  5.77 | ppl   319.79
| epoch   2 |   600/ 2983 batches | lr 5.00 | ms/batch  5.62 | loss  5.62 | ppl   276.16
| epoch   2 |   800/ 2983 batches | lr 5.00 | ms/batch  5.72 | loss  5.63 | ppl   277.32
| epoch   2 |  1000/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  5.60 | ppl   270.96
| epoch   2 |  1200/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  5.61 | ppl   273.71
| epoch   2 |  1400/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  5.62 | ppl   275.38
| epoch   2 |  1600/ 2983 batches | lr 5.00 | ms/batch  5.70 | loss  5.66 | ppl   286.58
| epoch   2 |  1800/ 2983 batches | lr 5.00 | ms/batch  5.74 | loss  5.54 | ppl   255.62
| epoch   2 |  2000/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  5.58 | ppl   264.36
| epoch   2 |  2200/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  5.48 | ppl   240.27
| epoch   2 |  2400/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  5.52 | ppl   248.69
| epoch   2 |  2600/ 2983 batches | lr 5.00 | ms/batch  5.62 | loss  5.53 | ppl   251.46
| epoch   2 |  2800/ 2983 batches | lr 5.00 | ms/batch  5.78 | loss  5.45 | ppl   233.75
-----------------------------------------------------------------------------------------
| end of epoch   2 | time: 18.00s | valid loss  5.53 | valid ppl   252.16
-----------------------------------------------------------------------------------------
| epoch   3 |   200/ 2983 batches | lr 5.00 | ms/batch  5.72 | loss  5.46 | ppl   235.25
| epoch   3 |   400/ 2983 batches | lr 5.00 | ms/batch  5.69 | loss  5.46 | ppl   234.59
| epoch   3 |   600/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  5.29 | ppl   197.90
| epoch   3 |   800/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  5.32 | ppl   204.71
| epoch   3 |  1000/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  5.31 | ppl   201.70
| epoch   3 |  1200/ 2983 batches | lr 5.00 | ms/batch  5.70 | loss  5.33 | ppl   205.88
| epoch   3 |  1400/ 2983 batches | lr 5.00 | ms/batch  5.59 | loss  5.35 | ppl   211.48
| epoch   3 |  1600/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  5.40 | ppl   220.79
| epoch   3 |  1800/ 2983 batches | lr 5.00 | ms/batch  6.03 | loss  5.29 | ppl   198.28
| epoch   3 |  2000/ 2983 batches | lr 5.00 | ms/batch  5.63 | loss  5.33 | ppl   206.45
| epoch   3 |  2200/ 2983 batches | lr 5.00 | ms/batch  5.62 | loss  5.23 | ppl   186.28
| epoch   3 |  2400/ 2983 batches | lr 5.00 | ms/batch  5.77 | loss  5.27 | ppl   194.13
| epoch   3 |  2600/ 2983 batches | lr 5.00 | ms/batch  5.62 | loss  5.29 | ppl   199.08
| epoch   3 |  2800/ 2983 batches | lr 5.00 | ms/batch  5.75 | loss  5.22 | ppl   184.77
-----------------------------------------------------------------------------------------
| end of epoch   3 | time: 18.10s | valid loss  5.45 | valid ppl   232.50
-----------------------------------------------------------------------------------------
| epoch   4 |   200/ 2983 batches | lr 5.00 | ms/batch  5.71 | loss  5.24 | ppl   189.07
| epoch   4 |   400/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  5.25 | ppl   190.61
| epoch   4 |   600/ 2983 batches | lr 5.00 | ms/batch  5.67 | loss  5.07 | ppl   159.83
| epoch   4 |   800/ 2983 batches | lr 5.00 | ms/batch  5.62 | loss  5.13 | ppl   168.20
| epoch   4 |  1000/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  5.12 | ppl   166.87
| epoch   4 |  1200/ 2983 batches | lr 5.00 | ms/batch  5.61 | loss  5.13 | ppl   169.07
| epoch   4 |  1400/ 2983 batches | lr 5.00 | ms/batch  5.60 | loss  5.17 | ppl   175.87
| epoch   4 |  1600/ 2983 batches | lr 5.00 | ms/batch  5.70 | loss  5.22 | ppl   184.63
| epoch   4 |  1800/ 2983 batches | lr 5.00 | ms/batch  5.69 | loss  5.12 | ppl   166.77
| epoch   4 |  2000/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  5.16 | ppl   173.80
| epoch   4 |  2200/ 2983 batches | lr 5.00 | ms/batch  5.71 | loss  5.05 | ppl   155.82
| epoch   4 |  2400/ 2983 batches | lr 5.00 | ms/batch  5.76 | loss  5.10 | ppl   163.49
| epoch   4 |  2600/ 2983 batches | lr 5.00 | ms/batch  5.71 | loss  5.12 | ppl   167.32
| epoch   4 |  2800/ 2983 batches | lr 5.00 | ms/batch  5.67 | loss  5.05 | ppl   155.76
-----------------------------------------------------------------------------------------
| end of epoch   4 | time: 18.03s | valid loss  5.42 | valid ppl   225.19
-----------------------------------------------------------------------------------------
| epoch   5 |   200/ 2983 batches | lr 5.00 | ms/batch  5.83 | loss  5.08 | ppl   160.77
| epoch   5 |   400/ 2983 batches | lr 5.00 | ms/batch  5.70 | loss  5.09 | ppl   163.02
| epoch   5 |   600/ 2983 batches | lr 5.00 | ms/batch  5.60 | loss  4.92 | ppl   137.13
| epoch   5 |   800/ 2983 batches | lr 5.00 | ms/batch  5.58 | loss  4.97 | ppl   143.72
| epoch   5 |  1000/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  4.96 | ppl   142.78
| epoch   5 |  1200/ 2983 batches | lr 5.00 | ms/batch  5.76 | loss  4.98 | ppl   146.04
| epoch   5 |  1400/ 2983 batches | lr 5.00 | ms/batch  5.67 | loss  5.03 | ppl   153.23
| epoch   5 |  1600/ 2983 batches | lr 5.00 | ms/batch  5.67 | loss  5.08 | ppl   160.29
| epoch   5 |  1800/ 2983 batches | lr 5.00 | ms/batch  5.67 | loss  4.98 | ppl   145.06
| epoch   5 |  2000/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  5.02 | ppl   151.17
| epoch   5 |  2200/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  4.90 | ppl   134.86
| epoch   5 |  2400/ 2983 batches | lr 5.00 | ms/batch  5.61 | loss  4.96 | ppl   142.85
| epoch   5 |  2600/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  4.98 | ppl   145.94
| epoch   5 |  2800/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  4.92 | ppl   136.60
-----------------------------------------------------------------------------------------
| end of epoch   5 | time: 17.99s | valid loss  5.39 | valid ppl   218.33
-----------------------------------------------------------------------------------------
| epoch   6 |   200/ 2983 batches | lr 5.00 | ms/batch  5.60 | loss  4.95 | ppl   140.86
| epoch   6 |   400/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  4.97 | ppl   143.35
| epoch   6 |   600/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  4.79 | ppl   120.55
| epoch   6 |   800/ 2983 batches | lr 5.00 | ms/batch  5.65 | loss  4.85 | ppl   127.48
| epoch   6 |  1000/ 2983 batches | lr 5.00 | ms/batch  5.64 | loss  4.84 | ppl   126.87
| epoch   6 |  1200/ 2983 batches | lr 5.00 | ms/batch  5.60 | loss  4.86 | ppl   129.41
| epoch   6 |  1400/ 2983 batches | lr 5.00 | ms/batch  5.66 | loss  4.91 | ppl   135.84
| epoch   6 |  1600/ 2983 batches | lr 5.00 | ms/batch  5.82 | loss  4.96 | ppl   143.08
| epoch   6 |  1800/ 2983 batches | lr 5.00 | ms/batch  5.68 | loss  4.86 | ppl   129.64
| epoch   6 |  2000/ 2983 batches | lr 5.00 | ms/batch  5.57 | loss  4.91 | ppl   134.98
| epoch   6 |  2200/ 2983 batches | lr 5.00 | ms/batch  5.80 | loss  4.79 | ppl   120.01
| epoch   6 |  2400/ 2983 batches | lr 5.00 | ms/batch  5.89 | loss  4.84 | ppl   126.87
| epoch   6 |  2600/ 2983 batches | lr 5.00 | ms/batch  5.79 | loss  4.87 | ppl   130.53
| epoch   6 |  2800/ 2983 batches | lr 5.00 | ms/batch  5.62 | loss  4.81 | ppl   122.77
-----------------------------------------------------------------------------------------
| end of epoch   6 | time: 18.09s | valid loss  5.37 | valid ppl   214.45
-----------------------------------------------------------------------------------------
| End of training | test loss  5.28 | test ppl   195.78

root@ca01b7709883:/workspace/examples/upstream/word_language_model# python generate.py --cuda
| Generated 0/1000 words
| Generated 100/1000 words
| Generated 200/1000 words
| Generated 300/1000 words
| Generated 400/1000 words
| Generated 500/1000 words
| Generated 600/1000 words
| Generated 700/1000 words
| Generated 800/1000 words
| Generated 900/1000 words
```

Updates #14

PiperOrigin-RevId: 534515559
2023-05-23 12:23:14 -07:00