DOCA Documentation v2.7.0
1.0

NVIDIA DOCA Developer Guide

This guide details the recommended steps to set up an NVIDIA DOCA development environment.

This guide is intended for software developers aiming to modify existing NVIDIA DOCA applications or develop their own DOCA-based software.

Instructions for installing DOCA on the NVIDIA® BlueField® Networking Platform (i.e., DPU or SuperNIC) can be found in the NVIDIA DOCA Installation Guide for Linux.

This guide focuses on the recommended flow for developing DOCA-based software, and will address the following scenarios:

It is recommended to follow the instructions for the first scenario, leveraging BlueField during the development and testing process.

This guide recommends using DOCA's development container during the development process on BlueField Platforms or on the host. Deploying development containers allows multiple developers to work simultaneously on the same device (host or BlueField Platform) in an isolated manner and even across multiple different DOCA SDK versions. This can allow multiple developers to work on the BlueField Platform itself, for example, without needing to have a dedicated BlueField per developer.

Another benefit of this container-based approach is that the development container allows developers to create and test their DOCA-based software in a user-friendly environment that comes pre-shipped with a set of handy development tools. The development container is focused on improving the development experience and is designed for that purpose, whereas the BlueField software is meant to be an efficient runtime environment for DOCA products.

Info

For questions, comments, and feedback, please contact us at DOCA-Feedback@exchange.nvidia.com.

Setup

DOCA's base image containers include a DOCA development container for the BlueField (doca:devel) which can be found on NGC. It is recommended to deploy this container on top of BlueField when preparing a development setup.

developing-using-bluefield-setup-version-1-modificationdate-1707815263100-api-v2.png

The recommended approach for working using DOCA's development container on top of the BlueField, is by using docker, which is already included in the supplied BFB image.

  1. Make sure the docker service is started. Run:

    Copy
    Copied!
                

    sudo systemctl daemon-reload sudo systemctl start docker

  2. Pull the container image:

    1. Visit the NGC page of the DOCA base image.

    2. Under the "Tags" menu, select the desired development tag for BlueField.

    3. The container tag for the docker pull command is copied to your clipboard once selected. Example docker pull command using the selected tag:

      Copy
      Copied!
                  

      sudo docker pull nvcr.io/nvidia/doca/doca:1.5.1-devel

  3. Once loaded locally, you may find the image's ID using the following command:

    Copy
    Copied!
                

    sudo docker images

    Example output:

    Copy
    Copied!
                

    REPOSITORY TAG IMAGE ID CREATED SIZE nvcr.io/nvidia/doca/doca 1.5.1-devel 931bd576eb49 10 months ago 1.49GB

  4. Run the docker image:

    Copy
    Copied!
                

    sudo docker run -v <source-code-folder>:/doca_devel -v /dev/hugepages:/dev/hugepages --privileged --net=host -it <image-name/ID>

    For example, to map a source folder named my_sources into the same container tag from the example above, the command should look like this:

    Copy
    Copied!
                

    sudo docker run -v my_sources:/doca_devel -v /dev/hugepages:/dev/hugepages --privileged --net=host -it nvcr.io/nvidia/doca/doca:1.5.1-devel

    After running the command, you get a shell inside the container where you can build your project using the regular build commands:

    • From the container's perspective, the mounted folder will be named /doca_devel

      Note

      Make sure to map a folder with write privileges to everyone. Otherwise, the docker would not be able to write the output files to it.

    • --net=host ensures the container has network access, including visibility to SFs and VFs as allocated on BlueField

    • -v /dev/hugepages:/dev/hugepages ensures that allocated huge pages are accessible to the container

Development

It is recommended to do the development within the doca:devel container. That said, some developers prefer different integrated development environments (IDEs) or development tools, and sometimes prefer working using a graphical IDE until it is time to compile the code. As such, the recommendation is to mount a network share to BlueField (refer to NVIDIA DOCA DPU CLI for more information) and to the container.

Note

Having the same code folder accessible from the IDE and the container helps prevent edge cases where the compilation fails due to a typo in the code, but the typo is only fixed locally within the container and not propagated to the main source folder.


Testing

The container is marked as "privileged", hence it can directly access the hardware capabilities of the BlueField Platform. This means that once the tested program compiles successfully, it can be directly tested from within the container without the need to copy it to BlueField and running it there.

Publishing

Once the program passes the testing phase, it should be prepared for deployment. While some proof-of-concept (POC) programs are just copied "as-is" in their binary form, most deployments will probably be in the form of a package (.deb/.rpm) or a container.

Construction of the binary package can be done as-is inside the current doca:devel container, or as part of a CI pipeline that will leverage the same development container as part of it.

For the construction of a container to ship the developed software, it is recommended to use a multi-staged build that ships the software on top of the runtime-oriented DOCA base images:

  • doca:base-rt – slim DOCA runtime environment

  • doca:full-rt – full DOCA runtime environment similar to the BlueField image

The runtime DOCA base images, alongside more details about their structure, can be found under the same NGC page that hosts the doca:devel image.

For a multi-staged build, it is recommended to compile the software inside the doca:devel container, and later copy it to one of the runtime container images. All relevant images must be pulled directly from NGC (using docker pull) to the container registry of BlueField.

If the development process needs to be done without access to a BlueField Platform, the recommendation is to use a QEMU-based deployment of a container on top of a regular x86 server. The development container for the host will be the same doca:devel image we mentioned previously.

developing-without-bluefield-setup-version-1-modificationdate-1707815262023-api-v2.png

Setup

  1. Make sure Docker is installed on your host. Run:

    Copy
    Copied!
                

    docker version

    If it is not installed, visit the official Install Docker Engine webpage for installation instructions.

  2. Install QEMU on the host.

    Note

    This step is for x86 hosts only. If you are working on an aarch64 host, move to the next step.

    Host OS

    Command

    Ubuntu

    Copy
    Copied!
                

    sudo apt-get install qemu binfmt-support qemu-user-static sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

    CentOS/RHEL 7.x

    Copy
    Copied!
                

    sudo yum install epel-release sudo yum install qemu-system-arm

    CentOS 8.0/8.2

    Copy
    Copied!
                

    sudo yum install epel-release sudo yum install qemu-kvm

    Fedora

    Copy
    Copied!
                

    sudo yum install qemu-system-aarch64

  3. If you are using CentOS or Fedora on the host, verify if qemu-aarch64.conf Run:

    Copy
    Copied!
                

    cat /etc/binfmt.d/qemu-aarch64.conf

    If it is missing, run:

    Copy
    Copied!
                

    echo ":qemu-aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-aarch64-static:" > /etc/binfmt.d/qemu-aarch64.conf

  4. If you are using CentOS or Fedora on the host, restart system binfmt. Run:

    Copy
    Copied!
                

    $ sudo systemctl restart systemd-binfmt

  5. To load and execute the development container, refer to the "Setup" section discussing the same docker-based deployment on the BlueField side.

Note

The doca:devel container supports multiple architectures. Therefore, Docker by default attempts to pull the one matching that of the current machine (i.e., amd64 for the host and arm64 for BlueField). Pulling the arm64 container from the x86 host can be done by adding the flag --platform=linux/arm64:

Copy
Copied!
            

sudo docker pull --platform=linux/arm64 nvcr.io/nvidia/doca/doca:1.5.1-devel


Development

Much like the development phase using a BlueField DPU, it is recommended to develop within the container running on top of QEMU.

Testing

While the compilation can be performed on top of the container, testing the compiled software must be done on top of a BlueField Platform. This is because the QEMU environment emulates an aarch64 architecture, but it does not emulate the hardware devices present on the BlueField Platform. Therefore, the tested program will not be able to access the devices needed for its successful execution, thus mandating that the testing is done on top of a physical BlueField.

Note

Make sure that the DOCA version used for compilation is the same as the version installed on BlueField used for testing.


Publishing

The publishing process is identical to the publishing process when using a BlueField DPU.

© Copyright 2024, NVIDIA. Last updated on Sep 9, 2024.