This project provides a development container for developing applications in SYCL for NVIDIA GPUs using the CUDA backend of the oneAPI DPC++ (Data Parallel C++) compiler.
It uses Podman as container engine to run the container rootless.
The setup has been tested on Fedora Linux 36 with Podman version 4.1.0.
Beside having installed Podman and VS Code, you need to setup the NVIDIA Container Toolkit before being able to start the development container.
You can install Podman on Fedora using
sudo dnf install -y podman
The instructions to set up the NVIDIA Container Toolkit are based on this guide by Red Hat.
-
Install the NVIDIA GPU driver using RPM Fusion. Note that you do not need to install CUDA, it is included in the container.
-
Configure the repository:
curl -sL https://nvidia.github.io/nvidia-docker/rhel9.0/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo
- Install the
nvidia-container-toolkit
package.
sudo dnf install -y nvidia-container-toolkit
- To allow running the container rootless, you need to apply 3 changes to
/etc/nvidia-container-runtime/config.toml
.
#no-cgroups = false
no-cgroups = true
#ldconfig = "@/sbin/ldconfig"
ldconfig = "/sbin/ldconfig"
#debug = "/var/log/nvidia-container-runtime.log"
debug = "~/.local/nvidia-container-runtime.log"
- Finally, install and apply a SELinux policy to enable GPU access within the container.
curl -sLO https://raw.githubusercontent.com/NVIDIA/dgx-selinux/master/bin/RHEL7/nvidia-container.pp
sudo semodule -i nvidia-container.pp
sudo nvidia-container-cli -k list | sudo restorecon -v -f -
sudo restorecon -Rv /dev
First install the Remote - Containers extension for VS Code.
By default, the extension is configured to use Docker, therefore you have to
go to user settings, Extensions, Remote - Containers, and change
Remote › Containers: Docker Path
to podman
.
Once you followed the setup instructions above, open this project in VS Code and you should see a prompt that suggests to reopen this project in a container.
The src
folder contains an example program. You can compile it, and any other source file,
by opening the source file in VS Code and executing the build task by pressing Ctrl+Shift+B
,
or open the Command Palette (F1
, Ctrl+Shift+P
) and search for Run Build Task.
Using the Command Palette, the compiled program can be executed via the Run Test Task.