├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── improvement-request.md │ └── vaccel-feature-request.md └── workflows │ ├── create_release.yml │ ├── e2e.yml │ └── fc_rootfs.yml ├── .gitignore ├── .gitmodules ├── README.md ├── build.sh ├── conf ├── config_vaccel.json ├── config_virtio_accel.json └── config_vsock.json ├── dockerfiles └── ubuntu │ └── latest │ └── Dockerfile └── scripts ├── build_agent.sh ├── build_firecracker.sh ├── build_jetson_plugin.sh ├── build_rootfs.sh ├── build_tf_plugin.sh ├── build_vaccelrt.sh ├── build_virtio.sh ├── build_virtio_plugin.sh ├── build_vsock_plugin.sh ├── create_tap.sh ├── download-models.sh ├── test_virtio.sh ├── test_vsock.sh └── utils.sh /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **Working environment** 14 | 1. Architecture (x86, Aarch64, other) 15 | 2. Linux flavour 16 | 3. Kernel version 17 | 4. Rust version (if applicable) 18 | 5. Other system-wide information that you think might be relevant 19 | 20 | **To Reproduce** 21 | Steps to reproduce the behavior: 22 | 1. Commit/version of vAccel at which the bug appears 23 | 2. vAccel setup 24 | * Host vs VM 25 | * Plugins 26 | * Environment variables 27 | 3. MWE or vAccel existing example with which the problem appears 28 | 29 | **Expected behavior** 30 | A clear and concise description of what you expected to happen. 31 | 32 | **Screenshots** 33 | If applicable, add screenshots to help explain your problem. 34 | 35 | **Additional context** 36 | Add any other context about the problem here. 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/improvement-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Improvement request 3 | about: Describe an improvement in the current state of the project 4 | title: "[IMPROVEMENT]" 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | Describe an improvement in the current state of the project and/or one of its submodules 11 | 12 | **Component(s) that need(s) improvement** 13 | Describe the list of components (top-level project and/or submodules) that are affected by this improvement 14 | 15 | **Describe the improvement** 16 | Describe in detail the changes required and the benefits that will introduce 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/vaccel-feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: vAccel feature request 3 | about: Describe a new feature request for vAccel framework 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/create_release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Create vAccel release 3 | 4 | on: 5 | workflow_dispatch: 6 | inputs: 7 | tag: 8 | description: "Tag to create release for" 9 | required: true 10 | default: 'warning' 11 | 12 | jobs: 13 | create_release: 14 | runs-on: [self-hosted] 15 | 16 | steps: 17 | - name: Setup vars 18 | id: vars 19 | run: | 20 | echo "::set-output name=uid::$(id -u)" 21 | echo "::set-output name=gid::$(id -g)" 22 | 23 | - name: Download artifacts 24 | uses: cloudkernels/minio-download@v2 25 | with: 26 | url: https://s3.nubificus.co.uk 27 | access-key: ${{ secrets.AWS_ACCESS_KEY }} 28 | secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 29 | remote-path: nbfc-assets/github/vaccel/${{github.event.inputs.tag}}/ 30 | local-path: /github/workspace/release/ 31 | env: 32 | ACTION_UID: ${{steps.vars.outputs.uid}} 33 | ACTION_GID: ${{steps.vars.outputs.gid}} 34 | 35 | - name: Create Release 36 | uses: marvinpinto/action-automatic-releases@latest 37 | with: 38 | repo_token: ${{secrets.GITHUB_TOKEN}} 39 | automatic_release_tag: ${{github.event.inputs.tag}} 40 | title: "vAccel release ${{github.event.inputs.tag}}" 41 | files: | 42 | release/vaccel_x86_64_Debug.tar.gz 43 | release/vaccel_x86_64_Release.tar.gz 44 | release/vaccel_aarch64_Debug.tar.gz 45 | release/vaccel_aarch64_Release.tar.gz 46 | 47 | -------------------------------------------------------------------------------- /.github/workflows/e2e.yml: -------------------------------------------------------------------------------- 1 | name: Test e2e vAccel 2 | 3 | on: 4 | # When a PR on main is opened 5 | pull_request: 6 | branches: 7 | - main 8 | paths: 9 | - agent 10 | - bindings 11 | - conf 12 | - firecracker 13 | - "plugins/**" 14 | - scripts/build_rootfs.sh 15 | - scripts/create_tap.sh 16 | - scripts/test_virtio.sh 17 | - scripts/test_vsock.sh 18 | - '!scripts/**' 19 | - vaccel-grpc 20 | - vaccelrt 21 | - virtio-accel 22 | - .github/workflows/e2e.yml 23 | 24 | # When something gets pushed to main 25 | push: 26 | branches: 27 | - main 28 | paths: 29 | - agent 30 | - bindings 31 | - conf 32 | - firecracker 33 | - "plugins/**" 34 | - scripts/build_rootfs.sh 35 | - scripts/create_tap.sh 36 | - scripts/test_virtio.sh 37 | - scripts/test_vsock.sh 38 | - '!scripts/**' 39 | - vaccel-grpc 40 | - vaccelrt 41 | - virtio-accel 42 | - .github/workflows/e2e.yml 43 | tags: 44 | - v* 45 | 46 | # Manually 47 | workflow_dispatch: 48 | 49 | jobs: 50 | prepare: 51 | runs-on: [self-hosted] 52 | outputs: 53 | vaccelrt_sha: ${{ steps.vars.outputs.vaccelrt_sha }} 54 | firecracker_sha: ${{ steps.vars.outputs.firecracker_sha }} 55 | virtio_accel_sha: ${{ steps.vars.outputs.virtio_accel_sha }} 56 | vsock_plugin_sha: ${{ steps.vars.outputs.vsock_plugin_sha }} 57 | virtio_plugin_sha: ${{ steps.vars.outputs.virtio_plugin_sha }} 58 | jetson_plugin_sha: ${{ steps.vars.outputs.jetson_plugin_sha }} 59 | agent_sha: ${{ steps.vars.outputs.agent_sha }} 60 | 61 | steps: 62 | - name: Cleanup previous runs 63 | run: | 64 | sudo rm -rf ${{ github.workspace }}/* 65 | sudo rm -rf ${{ github.workspace }}/.??* 66 | 67 | - uses: actions/checkout@v2 68 | 69 | - name: Setup vars 70 | id: vars 71 | run: | 72 | echo "::set-output name=vaccelrt_sha::$(git ls-tree ${{ github.sha }} | grep vaccelrt | awk '{print $3}')" 73 | echo "::set-output name=firecracker_sha::$(git ls-tree ${{ github.sha }} | grep firecracker | awk '{print $3}')" 74 | echo "::set-output name=virtio_accel_sha::$(git ls-tree ${{ github.sha }} | grep virtio-accel | awk '{print $3}')" 75 | echo "::set-output name=vsock_plugin_sha::$(git ls-tree ${{ github.sha }} plugins/vaccelrt-plugin-vsock | awk '{print $3}')" 76 | echo "::set-output name=virtio_plugin_sha::$(git ls-tree ${{ github.sha }} plugins/vaccelrt-plugin-virtio | awk '{print $3}')" 77 | echo "::set-output name=jetson_plugin_sha::$(git ls-tree ${{ github.sha }} plugins/vaccelrt-plugin-jetson | awk '{print $3}')" 78 | echo "::set-output name=agent_sha::$(git ls-tree ${{ github.sha }} agent | awk '{print $3}')" 79 | 80 | test: 81 | needs: prepare 82 | runs-on: [self-hosted, cloud, "${{ matrix.arch }}" ] 83 | env: 84 | NBFC_S3_ACCESS: ${{ secrets.AWS_ACCESS_KEY }} 85 | NBFC_S3_SECRET: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 86 | VACCELRT_SHA: ${{needs.prepare.outputs.vaccelrt_sha}} 87 | FIRECRACKER_SHA: ${{ needs.prepare.outputs.firecracker_sha }} 88 | VIRTIO_SHA: ${{ needs.prepare.outputs.virtio_accel_sha }} 89 | VIRTIO_PLUGIN_SHA: ${{ needs.prepare.outputs.virtio_plugin_sha }} 90 | VSOCK_PLUGIN_SHA: ${{ needs.prepare.outputs.vsock_plugin_sha }} 91 | AGENT_SHA: ${{ needs.prepare.outputs.agent_sha }} 92 | JOB_TYPE: ${{ matrix.build_type }} 93 | ARCH: ${{ matrix.arch }} 94 | 95 | strategy: 96 | matrix: 97 | build_type: [Debug, Release] 98 | arch: [x86_64, aarch64] 99 | fail-fast: false 100 | 101 | steps: 102 | - uses: actions/checkout@v2 103 | 104 | - name: Find SHA 105 | run: | 106 | # If we are in a PR, use the name of the branch that we want to merge, 107 | # otherwise "main" or tag name 108 | if [[ "${{github.event.pull_request.head.sha}}" != "" ]] 109 | then 110 | echo "ARTIFACT_NAME=$(echo ${{github.event.pull_request.head.ref}})" >> $GITHUB_ENV 111 | else 112 | echo "ARTIFACT_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV 113 | fi 114 | 115 | tail $GITHUB_ENV 116 | 117 | - name: Install packages 118 | run: | 119 | sudo apt update && sudo apt install -y \ 120 | subversion coreutils rsync iproute2 libfdt-dev pigz 121 | 122 | - name: Setup vars 123 | id: vars 124 | run: | 125 | echo "::set-output name=firecracker_build_type::$(echo ${{ matrix.build_type }} | awk '{print tolower($0)}')" 126 | echo "::set-output name=agent_build_type::$(echo ${{ matrix.build_type }} | awk '{print tolower($0)}')" 127 | echo "::set-output name=uid::$(id -u)" 128 | echo "::set-output name=gid::$(id -g)" 129 | 130 | - name: Fetch vaccelrt 131 | uses: cloudkernels/minio-download@v2 132 | with: 133 | url: https://s3.nubificus.co.uk 134 | access-key: ${{ env.NBFC_S3_ACCESS }} 135 | secret-key: ${{ env.NBFC_S3_SECRET }} 136 | local-path: /github/workspace/artifacts/opt/ 137 | remote-path: nbfc-assets/github/vaccelrt/${{env.VACCELRT_SHA}}/${{env.ARCH}}/${{ env.JOB_TYPE }}/opt/ 138 | env: 139 | ACTION_UID: ${{ steps.vars.outputs.uid }} 140 | ACTION_GID: ${{ steps.vars.outputs.gid }} 141 | 142 | 143 | - name: Fetch Firecracker 144 | uses: cloudkernels/minio-download@master 145 | with: 146 | url: https://s3.nubificus.co.uk 147 | access-key: ${{ env.NBFC_S3_ACCESS }} 148 | secret-key: ${{ env.NBFC_S3_SECRET }} 149 | remote-path: nbfc-assets/github/firecracker/${{ env.FIRECRACKER_SHA }}/${{env.ARCH}}/${{ steps.vars.outputs.firecracker_build_type }}/firecracker 150 | local-path: /github/workspace/artifacts/opt/bin/ 151 | env: 152 | ACTION_UID: ${{ steps.vars.outputs.uid }} 153 | ACTION_GID: ${{ steps.vars.outputs.gid }} 154 | 155 | - name: Fetch vmlinux 156 | uses: cloudkernels/minio-download@master 157 | with: 158 | url: https://s3.nubificus.co.uk 159 | access-key: ${{ env.NBFC_S3_ACCESS }} 160 | secret-key: ${{ env.NBFC_S3_SECRET }} 161 | remote-path: nbfc-assets/github/virtio-accel/${{ env.VIRTIO_SHA }}/${{env.ARCH}}/linux/vmlinux 162 | local-path: /github/workspace/artifacts/opt/share/ 163 | env: 164 | ACTION_UID: ${{ steps.vars.outputs.uid }} 165 | ACTION_GID: ${{ steps.vars.outputs.gid }} 166 | 167 | - name: Fetch virtio module 168 | uses: cloudkernels/minio-download@master 169 | with: 170 | url: https://s3.nubificus.co.uk 171 | access-key: ${{ env.NBFC_S3_ACCESS }} 172 | secret-key: ${{ env.NBFC_S3_SECRET }} 173 | remote-path: nbfc-assets/github/virtio-accel/${{ env.VIRTIO_SHA }}/${{env.ARCH}}/linux/virtio_accel.ko 174 | local-path: /github/workspace/artifacts/opt/share/ 175 | env: 176 | ACTION_UID: ${{ steps.vars.outputs.uid }} 177 | ACTION_GID: ${{ steps.vars.outputs.gid }} 178 | 179 | - name: Fetch virtio-plugin 180 | uses: cloudkernels/minio-download@v2 181 | with: 182 | url: https://s3.nubificus.co.uk 183 | access-key: ${{ env.NBFC_S3_ACCESS }} 184 | secret-key: ${{ env.NBFC_S3_SECRET }} 185 | local-path: /github/workspace/artifacts/opt/lib/ 186 | remote-path: nbfc-assets/github/vaccelrt/plugins/virtio/${{env.VIRTIO_PLUGIN_SHA}}/${{env.ARCH}}/${{ env.JOB_TYPE }}/libvaccel-virtio.so 187 | env: 188 | ACTION_UID: ${{ steps.vars.outputs.uid }} 189 | ACTION_GID: ${{ steps.vars.outputs.gid }} 190 | 191 | - name: Fetch vsock-plugin 192 | uses: cloudkernels/minio-download@v2 193 | with: 194 | url: https://s3.nubificus.co.uk 195 | access-key: ${{ env.NBFC_S3_ACCESS }} 196 | secret-key: ${{ env.NBFC_S3_SECRET }} 197 | local-path: /github/workspace/artifacts/opt/lib/ 198 | remote-path: nbfc-assets/github/vaccelrt/plugins/vsock/${{env.VSOCK_PLUGIN_SHA}}/${{env.ARCH}}/${{ env.JOB_TYPE }}/libvaccel-vsock.so 199 | env: 200 | ACTION_UID: ${{ steps.vars.outputs.uid }} 201 | ACTION_GID: ${{ steps.vars.outputs.gid }} 202 | 203 | - name: Fetch vAccel Agent 204 | uses: cloudkernels/minio-download@v2 205 | with: 206 | url: https://s3.nubificus.co.uk 207 | access-key: ${{ env.NBFC_S3_ACCESS }} 208 | secret-key: ${{ env.NBFC_S3_SECRET }} 209 | local-path: /github/workspace/artifacts/opt/bin/ 210 | remote-path: nbfc-assets/github/vaccelrt/agent/${{env.AGENT_SHA}}/${{env.ARCH}}/${{ steps.vars.outputs.agent_build_type }}/vaccelrt-agent 211 | env: 212 | ACTION_UID: ${{ steps.vars.outputs.uid }} 213 | ACTION_GID: ${{ steps.vars.outputs.gid }} 214 | 215 | - name: Fetch Firecracker root file system 216 | uses: cloudkernels/minio-download@v2 217 | with: 218 | url: https://s3.nubificus.co.uk 219 | access-key: ${{secrets.AWS_ACCESS_KEY}} 220 | secret-key: ${{secrets.AWS_SECRET_ACCESS_KEY}} 221 | local-path: /github/workspace/artifacts/opt/share/ 222 | remote-path: nbfc-assets/github/fc_rootfs/master/${{matrix.arch}}/rootfs.img.gz 223 | env: 224 | ACTION_UID: ${{steps.vars.outputs.uid}} 225 | ACTION_GID: ${{steps.vars.outputs.gid}} 226 | 227 | - name: Create rootfs 228 | run: | 229 | # We need this because downloading from s3 messes up with 230 | # file permissions 231 | chmod u+x ${{ github.workspace }}/artifacts/opt/bin/* 232 | pigz -d ${{ github.workspace }}/artifacts/opt/share/rootfs.img.gz 233 | sudo ./scripts/build_rootfs.sh \ 234 | --build_dir /tmp/rootfs_build \ 235 | --install_prefix ${{ github.workspace }}/artifacts/opt \ 236 | --base_image "ubuntu:latest" \ 237 | --dockerfiles_path "$(pwd)/dockerfiles" \ 238 | install_vaccel 239 | 240 | - name: Create tap interface 241 | run: sudo ./scripts/create_tap.sh tapTestFc 172.42.0.1/24 242 | 243 | - name: Launch Firecracker 244 | working-directory: ${{ github.workspace }}/artifacts/opt 245 | run: | 246 | sudo rm -f fc.sock 247 | sudo VACCEL_BACKENDS=${{ github.workspace }}/artifacts/opt/lib/libvaccel-noop.so \ 248 | LD_LIBRARY_PATH=${{ github.workspace }}/artifacts/opt/lib:/usr/local/lib:/usr/lib \ 249 | VACCEL_DEBUG_LEVEL=4 \ 250 | ./bin/firecracker \ 251 | --api-sock fc.sock \ 252 | --config-file ${{ github.workspace }}/conf/config_vaccel.json \ 253 | --seccomp-level 0 & 254 | 255 | - name: Test Firecracker is up 256 | run: ping -c 20 172.42.0.2 257 | 258 | - name: Test Firecracker ssh 259 | timeout-minutes: 2 260 | shell: bash {0} 261 | run: | 262 | while true 263 | do 264 | name=$(ssh -o StrictHostKeyChecking=no root@172.42.0.2 hostname -s) 265 | if [[ $name == "vaccel-guest" ]]; then exit 0; fi 266 | done 267 | exit 1 268 | 269 | - name: Test virtio-accel 270 | run: ./scripts/test_virtio.sh 271 | 272 | - name: Test vsock plugin 273 | run: | 274 | sudo LD_LIBRARY_PATH=${{ github.workspace }}/artifacts/opt/lib \ 275 | ./scripts/test_vsock.sh \ 276 | -p ${{ github.workspace }}/artifacts/opt/lib/libvaccel-noop.so \ 277 | --agent-prefix ${{ github.workspace }}/artifacts/opt/bin 278 | 279 | - name: Stop Firecracker 280 | timeout-minutes: 1 281 | shell: bash {0} 282 | run: | 283 | ssh -o StrictHostKeyChecking=no root@172.42.0.2 reboot 284 | # Wait for it to actually die 285 | sleep 10 286 | sync 287 | 288 | - name: Pack workflow artifact 289 | working-directory: ${{ github.workspace }}/artifacts/opt 290 | run: | 291 | cp ${{github.workspace}}/conf/{config_virtio_accel.json,config_vsock.json} share/ 292 | tar --use-compress-program="pigz -k --best" \ 293 | -cf ${{github.workspace}}/vaccel_${{matrix.arch}}_${{matrix.build_type}}.tar.gz \ 294 | bin/ include/ lib/ \ 295 | share/config_virtio_accel.json share/config_vsock.json \ 296 | share/rootfs.img share/virtio_accel.ko share/vmlinux \ 297 | share/vaccel.pc 298 | 299 | - name: Upload artifact to s3 300 | uses: cloudkernels/minio-upload@master 301 | with: 302 | url: https://s3.nubificus.co.uk 303 | access-key: ${{ env.NBFC_S3_ACCESS }} 304 | secret-key: ${{ env.NBFC_S3_SECRET }} 305 | remote-path: nbfc-assets/github/vaccel/${{ env.ARTIFACT_NAME }}/ 306 | local-path: /github/workspace/vaccel_${{matrix.arch}}_${{matrix.build_type}}.tar.gz 307 | 308 | - name: Cleanup run 309 | if: ${{ always() }} 310 | run: | 311 | sudo rm -rf ${{ github.workspace }}/* 312 | sudo rm -rf ${{ github.workspace }}/.??* 313 | sudo rm -f /tmp/vaccel.sock* 314 | sudo rm -rf /tmp/rootfs_build 315 | agent_pid=$(ps aux | grep -m 1 [v]accelrt-agent | awk '{print $2}') 316 | while true 317 | do 318 | agent_pid=$(ps aux | grep -m 1 [v]accelrt-agent | awk '{print $2}') 319 | if [[ $agent_pid == "" ]]; then break; fi 320 | echo "Killing vAccel agent (pid: $agent_pid)" 321 | sudo kill -9 $agent_pid 322 | # Wait for it to actually die 323 | sleep 2 324 | done 325 | sudo ip tuntap del tapTestFc mode tap 326 | 327 | invoke_create_release: 328 | if: startsWith(github.ref, 'refs/tags/v') 329 | needs: test 330 | runs-on: [self-hosted] 331 | 332 | steps: 333 | - name: Get tag name 334 | uses: olegtarasov/get-tag@v2.1 335 | id: tagName 336 | 337 | - name: Invoke workflow 338 | uses: benc-uk/workflow-dispatch@v1 339 | with: 340 | workflow: "Create vAccel release" 341 | token: ${{secrets.WORKFLOW_DISPATCH}} 342 | ref: ${{steps.tagName.outputs.tag}} 343 | inputs: '{ "tag": "${{steps.tagName.outputs.tag}}" }' 344 | -------------------------------------------------------------------------------- /.github/workflows/fc_rootfs.yml: -------------------------------------------------------------------------------- 1 | name: Build Firecracker rootfs 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | paths: 8 | - dockerfiles/ubuntu/latest/Dockerfile 9 | push: 10 | branches: 11 | - main 12 | paths: 13 | - dockerfiles/ubuntu/latest/Dockerfile 14 | workflow_dispatch: 15 | 16 | jobs: 17 | build_image: 18 | runs-on: [self-hosted, "${{ matrix.arch }}"] 19 | strategy: 20 | matrix: 21 | arch: [x86_64, aarch64] 22 | fail-fast: false 23 | 24 | steps: 25 | - uses: actions/checkout@v2 26 | 27 | - name: Install packages 28 | run: | 29 | sudo apt-get update && sudo apt-get install -y \ 30 | pigz 31 | 32 | - name: Build image 33 | run: | 34 | rm -rf build 35 | rm -rf output 36 | ./build.sh fc_rootfs build_base_rootfs 37 | pigz -9 output/debug/share/rootfs.img 38 | 39 | - name: Find SHA 40 | run: | 41 | if [[ "${{github.event.pull_request.head.sha}}" != "" ]] 42 | then 43 | echo "ARTIFACT_SHA=$(echo ${{github.event.pull_request.head.sha}})" >> $GITHUB_ENV 44 | else 45 | echo "ARTIFACT_SHA=master" >> $GITHUB_ENV 46 | fi 47 | 48 | - name: Upload artifact to s3 49 | uses: cloudkernels/minio-upload@master 50 | with: 51 | url: https://s3.nubificus.co.uk 52 | access-key: ${{ secrets.AWS_ACCESS_KEY }} 53 | secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 54 | local-path: output/debug/share/rootfs.img.gz 55 | remote-path: nbfc-assets/github/fc_rootfs/${{ env.ARTIFACT_SHA }}/${{ matrix.arch }}/ 56 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | # vim 55 | .*.swp 56 | .*.swo 57 | 58 | # repos output artifacts 59 | build 60 | output 61 | 62 | # Compilation cache 63 | **.ccls-cache/ 64 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vaccelrt"] 2 | path = vaccelrt 3 | url = https://github.com/cloudkernels/vaccelrt.git 4 | [submodule "firecracker"] 5 | path = firecracker 6 | url = https://github.com/cloudkernels/firecracker.git 7 | [submodule "virtio-accel"] 8 | path = virtio-accel 9 | url = https://github.com/cloudkernels/virtio-accel.git 10 | [submodule "vaccel-grpc"] 11 | path = vaccel-grpc 12 | url = https://github.com/cloudkernels/vaccel-grpc.git 13 | [submodule "vaccelrt-client"] 14 | path = vaccelrt-client 15 | url = https://github.com/cloudkernels/vaccelrt-client.git 16 | [submodule "agent"] 17 | path = agent 18 | url = https://github.com/nubificus/vaccelrt-agent 19 | [submodule "plugins/vaccelrt-plugin-vsock"] 20 | path = plugins/vaccelrt-plugin-vsock 21 | url = https://github.com/nubificus/vaccelrt-plugin-vsock.git 22 | [submodule "plugins/vaccelrt-plugin-virtio"] 23 | path = plugins/vaccelrt-plugin-virtio 24 | url = https://github.com/nubificus/vaccelrt-plugin-virtio.git 25 | [submodule "plugins/vaccelrt-plugin-jetson"] 26 | path = plugins/vaccelrt-plugin-jetson 27 | url = https://github.com/nubificus/vaccelrt-plugin-jetson.git 28 | [submodule "bindings/rust-bindings"] 29 | path = bindings/rust-bindings 30 | url = https://github.com/cloudkernels/vaccel-bindings.git 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vaccel 2 | A meta repo for gathering all the necessary components for running (and releasing) a vaccel environment. 3 | 4 | This repo is meant to track versions of the various components that work with 5 | each other, allow easy development locally using the build scripts and 6 | orchestrating e2e tests of the whole stack. 7 | 8 | ## Building 9 | 10 | The `build.sh` script allows you to build all the necessarry components, or one 11 | component at a time during development. It is using the component specific 12 | scripts under the `scripts` directory. 13 | 14 | For more info abou the script: 15 | 16 | ```bash 17 | ./build.sh --help 18 | ``` 19 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | # Some defaults 17 | # source directory 18 | SOURCEDIR="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" 19 | 20 | # top-level build directory 21 | BUILD_DIR=$(pwd)/build 22 | 23 | # install directory 24 | INSTALL_PREFIX=$(pwd)/output 25 | 26 | # Dockerfiles directory 27 | DOCKERFILES_DIR=$(pwd)/dockerfiles 28 | 29 | # Build type 30 | BUILD_TYPE=debug 31 | 32 | # Use container to build 33 | CTR_BUILD=no 34 | 35 | # name for logging 36 | LOG_NAME="vaccel build" 37 | 38 | source $SOURCEDIR/scripts/utils.sh 39 | 40 | print_build_options() { 41 | info "" 42 | info "Build options:" 43 | info " BUILD_DIR: $BUILD_DIR" 44 | info " INSTALL_PREFIX: $INSTALL_PREFIX" 45 | info " BUILD_TYPE: $BUILD_TYPE" 46 | info "" 47 | } 48 | 49 | prepare_build_env() { 50 | mkdir -p $INSTALL_PREFIX/$BUILD_TYPE/{lib,include,share,bin} 51 | mkdir -p $BUILD_DIR/$BUILD_TYPE 52 | } 53 | 54 | runctr() { 55 | docker run --rm \ 56 | -v $SOURCEDIR:$SOURCEDIR \ 57 | -v $BUILD_DIR:$BUILD_DIR \ 58 | -v $INSTALL_PREFIX:$INSTALL_PREFIX \ 59 | "$@" 60 | } 61 | 62 | runctr_vaccel_deps() { 63 | runctr nubificus/vaccel-deps:latest "$@" 64 | } 65 | 66 | # Build vAccelRT inside a container 67 | _build_vaccelrt_ctr() { 68 | info "Calling VaccelRT script inside container" 69 | runctr_vaccel_deps $SOURCEDIR/scripts/build_vaccelrt.sh \ 70 | --$BUILD_TYPE \ 71 | --src_dir $SOURCEDIR/vaccelrt \ 72 | --build_dir $BUILD_DIR/$BUILD_TYPE \ 73 | --install_prefix $INSTALL_PREFIX/$BUILD_TYPE 74 | ok_or_die "Could not build vaccelrt inside container" 75 | 76 | # Fix permissions 77 | runctr_vaccel_deps chown -R "$(id -u):$(id -g)" \ 78 | $BUILD_DIR/$BUILD_TYPE/vaccelrt \ 79 | $INSTALL_PREFIX/$BUILD_TYPE 80 | 81 | ok_or_die "Could not fix permissions for vaccelrt" 82 | } 83 | 84 | # Build vAccelRT on host 85 | _build_vaccelrt_host() { 86 | info "Calling VaccelRT script on host" 87 | ./scripts/build_vaccelrt.sh \ 88 | --build_dir $BUILD_DIR/$BUILD_TYPE \ 89 | --install_prefix $INSTALL_PREFIX/$BUILD_TYPE 90 | } 91 | 92 | build_vaccelrt() { 93 | [ "$CTR_BUILD" == yes ] && _build_vaccelrt_ctr || _build_vaccelrt_host 94 | } 95 | 96 | #Build Firecracker 97 | build_firecracker() { 98 | info "Calling firecracker script" 99 | ./scripts/build_firecracker.sh --$BUILD_TYPE --install_prefix $INSTALL_PREFIX/$BUILD_TYPE 100 | ok_or_die "Could not build firecracker" 101 | } 102 | 103 | _build_virtio_host() { 104 | info "Calling the virtio-accel build script on host" 105 | ./scripts/build_virtio.sh \ 106 | --build_dir $BUILD_DIR/$BUILD_TYPE \ 107 | --install_prefix $INSTALL_PREFIX/$BUILD_TYPE 108 | ok_or_die "Could not build virtio module" 109 | } 110 | 111 | _build_virtio_ctr() { 112 | info "Calling the virtio-accel build script inside container" 113 | runctr kernel-build-container:gcc-7 \ 114 | $SOURCEDIR/scripts/build_virtio.sh \ 115 | --build_dir $BUILD_DIR/$BUILD_TYPE \ 116 | --src_dir $SOURCEDIR/virtio-accel \ 117 | --install_prefix $INSTALL_PREFIX/$BUILD_TYPE 118 | ok_or_die "Could not build virtio module and Linux kernel" 119 | 120 | runctr kernel-build-container:gcc-7 \ 121 | chown -R "$(id -u):$(id -g)" \ 122 | $BUILD_DIR/$BUILD_TYPE/virtio-accel \ 123 | $INSTALL_PREFIX/$BUILD_TYPE 124 | ok_or_die "Could not fix permissions for virtio module and Linux kernel" 125 | } 126 | 127 | build_virtio() { 128 | [ "$CTR_BUILD" == yes ] && _build_virtio_ctr || _build_virtio_host 129 | } 130 | 131 | build_tf_plugin() { 132 | info "Calling TensorFlow plugin build script inside container" 133 | runctr nubificus/tensorflow \ 134 | $SOURCEDIR/scripts/build_tf_plugin.sh \ 135 | --$BUILD_TYPE \ 136 | --src_dir $SOURCEDIR/plugins/vaccelrt-plugin-tensorflow \ 137 | --build_dir $BUILD_DIR/$BUILD_TYPE \ 138 | --install_prefix $INSTALL_PREFIX/$BUILD_TYPE 139 | ok_or_die "Could not build TensorFlow plugin inside container" 140 | 141 | # Fix permissions 142 | runctr nubificus/tensorflow \ 143 | chown -R "$(id -u):$(id -g)" \ 144 | $BUILD_DIR/$BUILD_TYPE/tf-plugin \ 145 | $INSTALL_PREFIX/$BUILD_TYPE 146 | ok_or_die "Could not fix permissions for TensorFlow plugin" 147 | } 148 | 149 | build_virtio_plugin() { 150 | info "Calling VirtIO plugin build script" 151 | runctr nubificus/vaccel-deps \ 152 | $SOURCEDIR/scripts/build_virtio_plugin.sh \ 153 | --$BUILD_TYPE \ 154 | --src_dir $SOURCEDIR/plugins/vaccelrt-plugin-virtio \ 155 | --build_dir $BUILD_DIR/$BUILD_TYPE \ 156 | --install_prefix $INSTALL_PREFIX/$BUILD_TYPE 157 | ok_or_die "Could not build VirtIO plugin" 158 | 159 | # Fix permissions 160 | runctr nubificus/vaccel-deps \ 161 | chown -R "$(id -u):$(id -g)" \ 162 | $BUILD_DIR/$BUILD_TYPE/virtio-plugin \ 163 | $INSTALL_PREFIX/$BUILD_TYPE 164 | ok_or_die "Could not fix permissions for VirtIO plugin" 165 | } 166 | 167 | build_vsock_plugin() { 168 | info "Calling vsock plugin build script" 169 | runctr nubificus/vaccel-deps \ 170 | $SOURCEDIR/scripts/build_vsock_plugin.sh \ 171 | --$BUILD_TYPE \ 172 | --src_dir $SOURCEDIR/plugins/vaccelrt-plugin-vsock \ 173 | --build_dir $BUILD_DIR/$BUILD_TYPE \ 174 | --install_prefix $INSTALL_PREFIX/$BUILD_TYPE 175 | ok_or_die "Could not build vsock plugin" 176 | 177 | # Fix permissions 178 | runctr nubificus/vaccel-deps \ 179 | chown -R "$(id -u):$(id -g)" \ 180 | $BUILD_DIR/$BUILD_TYPE/vsock-plugin \ 181 | $INSTALL_PREFIX/$BUILD_TYPE 182 | ok_or_die "Could not fix permissions for vsock plugin" 183 | } 184 | 185 | build_fc_rootfs() { 186 | info "Calling the rootfs build script" 187 | ./scripts/build_rootfs.sh \ 188 | --install_prefix $INSTALL_PREFIX/$BUILD_TYPE \ 189 | --build_dir $BUILD_DIR/$BUILD_TYPE \ 190 | --base_image "ubuntu:latest" \ 191 | --dockerfiles_path $DOCKERFILES_DIR \ 192 | "$@" 193 | ok_or_die "Could not build rootfs" 194 | } 195 | 196 | download_models() { 197 | info "Downloading imagenet models" 198 | mkdir -p $INSTALL_PREFIX/$BUILD_TYPE/share/networks 199 | ./scripts/download-models.sh NO $INSTALL_PREFIX/$BUILD_TYPE/share/networks 200 | } 201 | 202 | build_plugins() { 203 | build_vsock_plugin 204 | build_virtio_plugin 205 | build_tf_plugin 206 | } 207 | 208 | build_vaccel_agent() { 209 | info "Building vAccel agent" 210 | 211 | ./scripts/build_agent.sh \ 212 | --$BUILD_TYPE \ 213 | --build_dir $BUILD_DIR/$BUILD_TYPE \ 214 | --install_prefix $INSTALL_PREFIX/$BUILD_TYPE 215 | } 216 | 217 | build_all() { 218 | build_vaccelrt 219 | build_firecracker 220 | build_virtio 221 | build_fc_rootfs all 222 | build_plugins 223 | build_vaccel_agent 224 | download_models 225 | } 226 | 227 | build_help() { 228 | echo "" 229 | echo "Vaccel build script" 230 | echo "Usage: $(basename $0) [] " 231 | echo "" 232 | echo "Arguments" 233 | echo " --release|--debug Build release or debug versions. (default:--debug)" 234 | echo " --build_dir The top-level build directory. (default: $(pwd)/build)" 235 | echo " --install_dir The directory to install output binaries. (default: $(pwd)/output)" 236 | echo " -c|--ctr_build Use container to build components, atm vAccelRT" 237 | echo " -h|--help Print this message and exit" 238 | echo "" 239 | echo "Available components to build:" 240 | echo "" 241 | echo " all" 242 | echo " build all Vaccel components" 243 | echo "" 244 | echo " vaccelrt" 245 | echo " build the VaccelRT runtime" 246 | echo "" 247 | echo " firecracker" 248 | echo " build Firecracker" 249 | echo "" 250 | echo " virtio" 251 | echo " build the vaccel-virtio module & corresponding kernel" 252 | echo "" 253 | echo " tf_plugin" 254 | echo " build the TensorFlow plugin" 255 | echo "" 256 | echo " virtio_plugin" 257 | echo " build the VirtIO plugin" 258 | echo "" 259 | echo " vsock_plugin" 260 | echo " build the vsock plugin" 261 | echo "" 262 | echo " plugins" 263 | echo " Build all plugins" 264 | echo "" 265 | echo " fc_rootfs" 266 | echo " build a rootfs image for firecracker" 267 | echo "" 268 | echo " vaccel_agent" 269 | echo " build vAccel agent" 270 | echo "" 271 | echo " imagenet-models" 272 | echo " Download imagenet network models" 273 | echo "" 274 | } 275 | 276 | main() { 277 | if [ $# == 0 ]; then 278 | die "Insufficient script arguments. Use \`$0 --help\` for help." 279 | fi 280 | 281 | while [ $# -gt 0 ]; do 282 | case "$1" in 283 | -h|--help) { build_help; exit 1; };; 284 | --release) { BUILD_TYPE=release; };; 285 | --debug) { BUILD_TYPE=debug; };; 286 | --build_dir) { BUILD_DIR=$2; shift; };; 287 | --install_dir) { INSTALL_PREFIX=$2; shift; };; 288 | -c|--ctr_build) { CTR_BUILD=yes; };; 289 | -*) 290 | die "Unkown argument: $1. Please use \`$0 help\`." 291 | ;; 292 | *) 293 | break; 294 | ;; 295 | esac 296 | shift 297 | done 298 | 299 | print_build_options 300 | 301 | # Make sure that $1 is a valid command 302 | declare -f "build_$1" > /dev/null 303 | ok_or_die "Unkown command: $1. Please use \`$0 help\`." 304 | 305 | cmd=build_$1 306 | shift 307 | 308 | # Create all the necessary directories 309 | prepare_build_env 310 | 311 | # Call the command and pass it the remaining arguments. 312 | # At the moment no arguments are passed in the commands, but keep 313 | # it like this for the future 314 | $cmd "$@" 315 | } 316 | 317 | main "$@" 318 | -------------------------------------------------------------------------------- /conf/config_vaccel.json: -------------------------------------------------------------------------------- 1 | { 2 | "boot-source": { 3 | "kernel_image_path": "share/vmlinux", 4 | "boot_args": "console=ttyS0 reboot=k panic=1 pci=off loglevel=8 root=/dev/vda ip=172.42.0.2::172.42.0.1:255.255.255.0::eth0:off random.trust_cpu=on" 5 | }, 6 | "drives": [ 7 | { 8 | "drive_id": "rootfs", 9 | "path_on_host": "share/rootfs.img", 10 | "is_root_device": true, 11 | "is_read_only": false 12 | } 13 | ], 14 | "network-interfaces": [ 15 | { 16 | "iface_id": "eth0", 17 | "guest_mac": "AA:FC:00:00:00:01", 18 | "host_dev_name": "tapTestFc" 19 | } 20 | ], 21 | "crypto": { 22 | "crypto_dev_id": "vaccel0", 23 | "host_crypto_dev": "/dev/vaccel0" 24 | }, 25 | "machine-config": { 26 | "vcpu_count": 2, 27 | "mem_size_mib": 4096, 28 | "ht_enabled": false 29 | }, 30 | "vsock": { 31 | "guest_cid": 42, 32 | "uds_path": "/tmp/vaccel.sock", 33 | "vsock_id": "root" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /conf/config_virtio_accel.json: -------------------------------------------------------------------------------- 1 | { 2 | "boot-source": { 3 | "kernel_image_path": "share/vmlinux", 4 | "boot_args": "console=ttyS0 reboot=k panic=1 pci=off loglevel=8 root=/dev/vda ip=172.42.0.2::172.42.0.1:255.255.255.0::eth0:off random.trust_cpu=on" 5 | }, 6 | "drives": [ 7 | { 8 | "drive_id": "rootfs", 9 | "path_on_host": "share/rootfs.img", 10 | "is_root_device": true, 11 | "is_read_only": false 12 | } 13 | ], 14 | "network-interfaces": [ 15 | { 16 | "iface_id": "eth0", 17 | "guest_mac": "AA:FC:00:00:00:01", 18 | "host_dev_name": "tapTestFc" 19 | } 20 | ], 21 | "crypto": { 22 | "crypto_dev_id": "vaccel0", 23 | "host_crypto_dev": "/dev/vaccel0" 24 | }, 25 | "machine-config": { 26 | "vcpu_count": 2, 27 | "mem_size_mib": 4096, 28 | "ht_enabled": false 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /conf/config_vsock.json: -------------------------------------------------------------------------------- 1 | { 2 | "boot-source": { 3 | "kernel_image_path": "share/vmlinux", 4 | "boot_args": "console=ttyS0 reboot=k panic=1 pci=off loglevel=8 root=/dev/vda ip=172.42.0.2::172.42.0.1:255.255.255.0::eth0:off random.trust_cpu=on" 5 | }, 6 | "drives": [ 7 | { 8 | "drive_id": "rootfs", 9 | "path_on_host": "share/rootfs.img", 10 | "is_root_device": true, 11 | "is_read_only": false 12 | } 13 | ], 14 | "network-interfaces": [ 15 | { 16 | "iface_id": "eth0", 17 | "guest_mac": "AA:FC:00:00:00:01", 18 | "host_dev_name": "tapTestFc" 19 | } 20 | ], 21 | "machine-config": { 22 | "vcpu_count": 2, 23 | "mem_size_mib": 4096, 24 | "ht_enabled": false 25 | }, 26 | "vsock": { 27 | "guest_cid": 42, 28 | "uds_path": "/tmp/vaccel.sock", 29 | "vsock_id": "root" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /dockerfiles/ubuntu/latest/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest as rootfs-builder 2 | 3 | ENV DEBIAN_FRONTEND=noninteractive 4 | 5 | ARG KERNEL_VERSION 6 | 7 | RUN apt-get update && apt-get install -y \ 8 | init \ 9 | kmod \ 10 | openssh-server \ 11 | udev \ 12 | gdb \ 13 | valgrind \ 14 | rsync \ 15 | iproute2 && \ 16 | apt-get clean 17 | 18 | # Prepare immutable vAccel properties 19 | RUN mkdir -p /opt/vaccel 20 | RUN echo "/opt/vaccel/lib" >> /etc/ld.so.conf.d/vaccel.conf 21 | RUN echo "/sbin/ldconfig" >> /root/.bashrc 22 | RUN echo "export VACCEL_BACKENDS=/opt/vaccel/lib/libvaccel-vsock.so" >> /root/.bashrc 23 | RUN echo "export VACCEL_DEBUG_LEVEL=4" >> /root/.bashrc 24 | 25 | # Enable ssh server 26 | RUN systemctl enable ssh 27 | RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config 28 | RUN echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config 29 | 30 | # Disable root password 31 | RUN sed s/root\:x\:/root\:\:/ -i /etc/passwd 32 | RUN sed s/root\:\*\:/root\:\:/ -i /etc/shadow 33 | 34 | # Set hostname 35 | RUN echo "vaccel-guest.nubificus.co.uk" > /etc/hostname 36 | 37 | # Write out everything 38 | FROM scratch as artifact 39 | COPY --from=rootfs-builder / /rootfs 40 | -------------------------------------------------------------------------------- /scripts/build_agent.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # retrieve path 16 | SCRIPTPATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ) 17 | 18 | # Default build type 19 | BUILD_TYPE=debug 20 | 21 | # plugin source directory 22 | SRC_DIR="$(pwd)/agent" 23 | 24 | # Build directory 25 | BUILD_DIR="$(pwd)/build" 26 | 27 | # Default installation directory 28 | INSTALL_PREFIX="$(pwd)/output" 29 | 30 | # script name for logging 31 | LOG_NAME="$(basename $0)" 32 | 33 | source $SCRIPTPATH/utils.sh 34 | 35 | print_args() { 36 | info "Build arguments" 37 | info " BUILD_TYPE: $BUILD_TYPE" 38 | info " SRC_DIR: $SRC_DIR" 39 | info " BUILD_DIR: $BUILD_DIR" 40 | info " INSTALL_PREFIX: $INSTALL_PREFIX" 41 | info "" 42 | } 43 | 44 | print_help() { 45 | echo "" 46 | echo "Usage: build_agent.sh []" 47 | echo "" 48 | echo "Arguments:" 49 | echo " --release|--debug Type of build (default: debug)" 50 | echo " --src_dir vAccel source directory (default: \`\$(pwd)/agent\`)" 51 | echo " --build_dir Directory to use for out-of-source build (default: 'build')" 52 | echo " --install_prefix Directory to install library (default: 'output')" 53 | echo " -h|--help Print this message and exit" 54 | echo "" 55 | } 56 | 57 | 58 | prepare_env() { 59 | mkdir -p $BUILD_DIR/vaccel-agent 60 | info "Build directory: $BUILD_DIR/vaccel-agent" 61 | } 62 | 63 | build() { 64 | cd $SRC_DIR 65 | 66 | # Build the crate 67 | if [[ $BUILD_TYPE == "debug" ]]; then 68 | info "Building debug version" 69 | cargo build --target-dir $BUILD_DIR/vaccel-agent 70 | else 71 | info "Building release version" 72 | cargo build --release --target-dir $BUILD_DIR/vaccel-agent 73 | fi 74 | 75 | ok_or_die "Could not build vAccel agent" 76 | 77 | # Install the binary 78 | mkdir -p $INSTALL_PREFIX/bin 79 | cp $BUILD_DIR/vaccel-agent/$BUILD_TYPE/vaccelrt-agent $INSTALL_PREFIX/bin/ 80 | 81 | cd - 82 | } 83 | 84 | main() { 85 | while [ $# -gt 0 ]; do 86 | case "$1" in 87 | -h|--help) { print_help; exit 1; };; 88 | --release) { BUILD_TYPE=release; };; 89 | --debug) { BUILD_TYPE=debug; };; 90 | --src_dir) { SRC_DIR=$2; shift; };; 91 | --build_dir) { BUILD_DIR=$2; shift; };; 92 | --install_prefix) { INSTALL_PREFIX=$2; shift; };; 93 | *) 94 | die "Unknown argument: \"$1\". Please use \`$0 --help\`." 95 | ;; 96 | esac 97 | shift 98 | done 99 | 100 | print_args 101 | 102 | # Prepare build environment 103 | prepare_env 104 | 105 | # and build 106 | build 107 | } 108 | 109 | main "$@" 110 | -------------------------------------------------------------------------------- /scripts/build_firecracker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # retrieve path 16 | SCRIPTPATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ) 17 | 18 | # Default build type 19 | BUILD_TYPE=debug 20 | 21 | # Default installation directory 22 | INSTALL_PREFIX=output 23 | 24 | # script name for logging 25 | LOG_NAME="$(basename $0)" 26 | 27 | source $SCRIPTPATH/utils.sh 28 | 29 | print_help() { 30 | echo "" 31 | echo "Usage: build_firecracker.sh []" 32 | echo "" 33 | echo "Arguments:" 34 | echo " --release|--debug Type of build (default: debug)" 35 | echo " --install_prefix Installation directory of firecracker binary" 36 | echo "" 37 | } 38 | 39 | build_fc() { 40 | info "Building firecracker (build_type: $BUILD_TYPE install_prefix: $INSTALL_PREFIX)" 41 | 42 | ./firecracker/tools/devtool build -l gnu --$BUILD_TYPE 43 | ok_or_die "Error building firecracker" 44 | 45 | mkdir -p ${INSTALL_PREFIX}/bin 46 | cp firecracker/build/cargo_target/x86_64-unknown-linux-gnu/$BUILD_TYPE/firecracker $INSTALL_PREFIX/bin 47 | cp conf/config_virtio_accel.json $INSTALL_PREFIX/share/ 48 | cp conf/config_vsock.json $INSTALL_PREFIX/share/ 49 | ok_or_die "Could not copy firecracker binary to destination" 50 | 51 | info "Copied firecracker binary to $INSTALL_PREFIX/bin" 52 | } 53 | 54 | main() { 55 | while [[ $# -gt 0 ]]; do 56 | case "$1" in 57 | -h|--help) { print_help; exit 1; };; 58 | --release) { BUILD_TYPE=release; };; 59 | --debug) { BUILD_TYPE=debug; };; 60 | --install_prefix) { INSTALL_PREFIX=$2; shift; };; 61 | *) 62 | die "Unknown argument: \"$1\". Please use \`$0 --help\`." 63 | ;; 64 | esac 65 | shift 66 | done 67 | 68 | # Build firecracker and copy binary to installation directory 69 | build_fc 70 | } 71 | 72 | main "$@" 73 | -------------------------------------------------------------------------------- /scripts/build_jetson_plugin.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # retrieve path 16 | SCRIPTPATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ) 17 | 18 | # Default build type 19 | BUILD_TYPE=Debug 20 | 21 | # vaccelrt source directory 22 | SRC_DIR="$(pwd)/plugins/vaccelrt-plugin-jeston" 23 | 24 | # Build directory 25 | BUILD_DIR="$(pwd)/build" 26 | 27 | # Default installation directory 28 | INSTALL_PREFIX="$(pwd)/output" 29 | 30 | # script name for logging 31 | LOG_NAME="$(basename $0)" 32 | 33 | source $SCRIPTPATH/utils.sh 34 | 35 | print_args() { 36 | info "Build arguments" 37 | info " BUILD_TYPE: $BUILD_TYPE" 38 | info " SRC_DIR: $SRC_DIR" 39 | info " BUILD_DIR: $BUILD_DIR" 40 | info " INSTALL_PREFIX: $INSTALL_PREFIX" 41 | info "" 42 | } 43 | 44 | print_help() { 45 | echo "" 46 | echo "Usage: build_vaccelrt.sh []" 47 | echo "" 48 | echo "Arguments:" 49 | echo " --release|--debug Type of build (default: debug)" 50 | echo " --src_dir VaccelRT source directory (default: \`\$(pwd)/vaccelrt\`)" 51 | echo " --build_dir Directory to use for out-of-source build (default: 'build')" 52 | echo " --install_prefix Directory to install library (default: 'output')" 53 | echo "" 54 | } 55 | 56 | 57 | prepare_env() { 58 | mkdir -p $BUILD_DIR/jetson-plugin 59 | } 60 | 61 | build() { 62 | cd $BUILD_DIR/jetson-plugin 63 | # Configure Cmake 64 | cmake $SRC_DIR \ 65 | -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \ 66 | -DCMAKE_BUILD_TYPE=$BUILD_TYPE 67 | ok_or_die "Could not configure cmake" 68 | 69 | # Build and install 70 | cmake --build . --config ${BUILD_TYPE} 71 | ok_or_die "Could not build" 72 | 73 | make install 74 | ok_or_die "Could not install" 75 | 76 | cd - 77 | } 78 | 79 | main() { 80 | while [ $# -gt 0 ]; do 81 | case "$1" in 82 | -h|--help) { print_help; exit 1; };; 83 | --release) { BUILD_TYPE=Release; };; 84 | --debug) { BUILD_TYPE=Debug; };; 85 | --src_dir) { SRC_DIR=$2; shift; };; 86 | --build_dir) { BUILD_DIR=$2; shift; };; 87 | --install_prefix) { INSTALL_PREFIX=$2; shift; };; 88 | *) 89 | die "Unknown argument: \"$1\". Please use \`$0 --help\`." 90 | ;; 91 | esac 92 | shift 93 | done 94 | 95 | print_args 96 | 97 | # Prepare build environment 98 | prepare_env 99 | 100 | # and build 101 | build 102 | } 103 | 104 | main "$@" 105 | -------------------------------------------------------------------------------- /scripts/build_rootfs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # retrieve path 16 | SCRIPTPATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ) 17 | 18 | # Build directory 19 | BUILD_DIR=build 20 | 21 | # Default installation directory 22 | INSTALL_PREFIX=output 23 | 24 | # Dockerfiles path 25 | DOCKERFILES_PATH="dockerfiles" 26 | 27 | # Base image to use 28 | BASE_IMAGE="ubuntu:latest" 29 | 30 | # script name for logging 31 | LOG_NAME="$(basename $0)" 32 | 33 | source $SCRIPTPATH/utils.sh 34 | 35 | fetch_from_git() { 36 | local git_url="https://github.com/$1" 37 | local dest_dir="$2" 38 | 39 | svn export $git_url $dest_dir 40 | } 41 | 42 | print_help() { 43 | echo "" 44 | echo "Usage: build_rootfs.sh []" 45 | echo "" 46 | echo "Arguments:" 47 | echo " --help|-h Print this message and exit" 48 | echo " --build_dir Directory to use for building (default: 'build')" 49 | echo " --install_prefix Directory to install library (default: 'output')" 50 | echo " --base_image Base image to use (default: ubuntu:latest)" 51 | echo " --dockerfiles_path Path to find dockerfiles for base images (default: dockerfiles)" 52 | echo "" 53 | echo "Available sub-commands" 54 | echo "" 55 | echo " build_base_rootfs" 56 | echo " Build the base root file system (without vAccel binaries installed)" 57 | echo "" 58 | echo " install_vaccel" 59 | echo " Install vAccel binaries inside root file system" 60 | echo "" 61 | echo " all" 62 | echo " Build the base rootfs and then install the vAccel binaries in it" 63 | echo "" 64 | echo " help" 65 | echo " Print this message" 66 | echo "" 67 | } 68 | 69 | 70 | build_base_rootfs() { 71 | info "Building base Firecracker root filesystem" 72 | mkdir -p ${BUILD_DIR}/rootfs 73 | cd ${BUILD_DIR}/rootfs 74 | 75 | # Fetch Dockerfile on which we'll base the image 76 | local image=$(echo "${BASE_IMAGE}" | awk -F ":" '{print $1}') 77 | local tag=$(echo "${BASE_IMAGE}" | awk -F ":" '{print $2}') 78 | 79 | info "Copying Dockerfile from: ${DOCKERFILES_PATH}/${image}/${tag}" 80 | if [ ! -f "${DOCKERFILES_PATH}/${image}/${tag}/Dockerfile" ]; then 81 | die "Could not find base image" 82 | fi 83 | 84 | cp ${DOCKERFILES_PATH}/${image}/${tag}/Dockerfile . 85 | ok_or_die "Could not find Dockerfile for ${BASE_IMAGE}" 86 | 87 | info "Build root filesystem from Dockerfile" 88 | # Create root filesystem 89 | DOCKER_BUILDKIT=1 docker build \ 90 | --network=host \ 91 | -t vaccel-rootfs \ 92 | --build-arg "KERNEL_VERSION=5.10.0" \ 93 | --output type=local,dest=. . 94 | ok_or_die "Could not build the base rootfs" 95 | 96 | info "Prepare rootfs.img" 97 | dd if=/dev/zero of=rootfs.img bs=1M count=0 seek=1024 98 | sudo mkfs.ext4 rootfs.img 99 | ok_or_die "Could not create filesystem for rootfs" 100 | 101 | info "Copy rootfs in img file" 102 | mkdir -p mnt 103 | mnt="$(mktemp -d)" 104 | sudo mount rootfs.img $mnt 105 | ok_or_die "Could not mount rootfs" 106 | 107 | sudo rsync -aogxvPH rootfs/* $mnt 108 | 109 | # Setup nameserver 110 | # We need to do it here, because Docker does not let us change its 111 | # rootfs 112 | echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf 113 | 114 | sudo chown -R root:root $mnt/root 115 | ok_or_die "Could not populate rootfs" 116 | 117 | sudo umount $mnt 118 | ok_or_die "Could not unmount rootfs" 119 | 120 | sudo sync 121 | sudo rmdir $mnt 122 | 123 | info "Install rootfs.img under ${INSTALL_PREFIX}/share" 124 | cp rootfs.img ${INSTALL_PREFIX}/share/ 125 | } 126 | 127 | install_vaccel() { 128 | info "Installing vAccel in root filesystem" 129 | mkdir -p ${BUILD_DIR}/rootfs 130 | cd ${BUILD_DIR}/rootfs 131 | 132 | if [ ! -f $INSTALL_PREFIX/share/rootfs.img ]; then 133 | die "Base root file system is not built" 134 | fi 135 | 136 | mnt="$(mktemp -d)" 137 | sudo mount $INSTALL_PREFIX/share/rootfs.img $mnt 138 | ok_or_die "Could not mount rootfs" 139 | 140 | if [[ ! -d $mnt/opt/vaccel ]] ; then 141 | die "Base rootfs is not built properly" 142 | fi 143 | 144 | info "Copying files" 145 | cp -r $INSTALL_PREFIX/{bin,lib,include} $mnt/opt/vaccel/ 146 | 147 | mkdir -p $mnt/opt/vaccel/share 148 | cp -r $INSTALL_PREFIX/share/models $mnt/opt/vaccel/share 149 | ok_or_die "Could not copy ML models" 150 | 151 | mkdir -p $mnt/opt/vaccel/share/images 152 | fetch_from_git dusty-nv/jetson-inference/trunk/data/images/dog_1.jpg $mnt/opt/vaccel/share/images/dog_1.jpg 153 | ok_or_die "Could not download example image" 154 | 155 | info "Setup VirtIO module" 156 | # Setup VirtIO module (hardcoded kernel version) 157 | mkdir -p $mnt/lib/modules/5.10.0 158 | cp $INSTALL_PREFIX/share/virtio_accel.ko $mnt/lib/modules/5.10.0 159 | touch $mnt/lib/modules/5.10.0/modules.order 160 | touch $mnt/lib/modules/5.10.0/modules.builtin 161 | echo "virtio_accel" >> $mnt/etc/modules 162 | sudo chroot $mnt /sbin/depmod 5.10.0 163 | 164 | sudo sync 165 | sudo umount $mnt 166 | ok_or_die "Could not unmount root file system" 167 | } 168 | 169 | all() { 170 | build_base_rootfs 171 | install_vaccel 172 | } 173 | 174 | main() { 175 | if [ $# == 0 ]; then 176 | die "Insufficient script arguments. Use \`$0 --help\'." 177 | fi 178 | 179 | while [ $# -gt 0 ]; do 180 | case "$1" in 181 | -h|--help) { print_help; exit 1; };; 182 | --build_dir) { BUILD_DIR=$2; shift; };; 183 | --install_prefix) { INSTALL_PREFIX=$2; shift; };; 184 | --base_image) { BASE_IMAGE=$2; shift; };; 185 | --dockerfiles_path) { DOCKERFILES_PATH=$2; shift; };; 186 | *-) 187 | die "Unknown argument: \"$1\". Please use \`$0 --help\`." 188 | ;; 189 | *) 190 | break; 191 | ;; 192 | esac 193 | shift 194 | done 195 | 196 | # Make sure that $1 is a valid command 197 | declare -f "$1" > /dev/null 198 | ok_or_die "Unknown command: '$1'. Please use \`$0 --help\`." 199 | 200 | $1 "$@" 201 | } 202 | 203 | main "$@" 204 | -------------------------------------------------------------------------------- /scripts/build_tf_plugin.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # retrieve path 16 | SCRIPTPATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ) 17 | 18 | # Default build type 19 | BUILD_TYPE=Debug 20 | 21 | # plugin source directory 22 | SRC_DIR="$(pwd)/plugins/vaccelrt-plugin-tensorflow" 23 | 24 | # Build directory 25 | BUILD_DIR="$(pwd)/build" 26 | 27 | # Default installation directory 28 | INSTALL_PREFIX="$(pwd)/output" 29 | 30 | # script name for logging 31 | LOG_NAME="$(basename $0)" 32 | 33 | source $SCRIPTPATH/utils.sh 34 | 35 | print_args() { 36 | info "Build arguments" 37 | info " BUILD_TYPE: $BUILD_TYPE" 38 | info " SRC_DIR: $SRC_DIR" 39 | info " BUILD_DIR: $BUILD_DIR" 40 | info " INSTALL_PREFIX: $INSTALL_PREFIX" 41 | info "" 42 | } 43 | 44 | print_help() { 45 | echo "" 46 | echo "Usage: build_tf_plugin.sh []" 47 | echo "" 48 | echo "Arguments:" 49 | echo " --release|--debug Type of build (default: debug)" 50 | echo " --src_dir TensorFlow plugin source directory (default: \`\$(pwd)/plugins/vaccelrt-plugin-tensorflow\`)" 51 | echo " --build_dir Directory to use for out-of-source build (default: 'build')" 52 | echo " --install_prefix Directory to install library (default: 'output')" 53 | echo "" 54 | } 55 | 56 | 57 | prepare_env() { 58 | mkdir -p $BUILD_DIR/tf-plugin 59 | info "Build directory: $BUILD_DIR/tf-plugin" 60 | } 61 | 62 | build() { 63 | cd $BUILD_DIR/tf-plugin 64 | # Configure Cmake 65 | cmake $SRC_DIR \ 66 | -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \ 67 | -DCMAKE_BUILD_TYPE=$BUILD_TYPE 68 | ok_or_die "Could not configure cmake" 69 | 70 | # Build and install 71 | cmake --build . --config ${BUILD_TYPE} 72 | ok_or_die "Could not build" 73 | 74 | make install 75 | ok_or_die "Could not install" 76 | 77 | cd - 78 | } 79 | 80 | main() { 81 | while [ $# -gt 0 ]; do 82 | case "$1" in 83 | -h|--help) { print_help; exit 1; };; 84 | --release) { BUILD_TYPE=Release; };; 85 | --debug) { BUILD_TYPE=Debug; };; 86 | --src_dir) { SRC_DIR=$2; shift; };; 87 | --build_dir) { BUILD_DIR=$2; shift; };; 88 | --install_prefix) { INSTALL_PREFIX=$2; shift; };; 89 | *) 90 | die "Unknown argument: \"$1\". Please use \`$0 --help\`." 91 | ;; 92 | esac 93 | shift 94 | done 95 | 96 | print_args 97 | 98 | # Prepare build environment 99 | prepare_env 100 | 101 | # and build 102 | build 103 | } 104 | 105 | main "$@" 106 | -------------------------------------------------------------------------------- /scripts/build_vaccelrt.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # retrieve path 16 | SCRIPTPATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ) 17 | 18 | # Default build type 19 | BUILD_TYPE=Debug 20 | 21 | # vaccelrt source directory 22 | SRC_DIR="$(pwd)/vaccelrt" 23 | 24 | # Build directory 25 | BUILD_DIR="$(pwd)/build" 26 | 27 | # Default installation directory 28 | INSTALL_PREFIX="$(pwd)/output" 29 | 30 | # script name for logging 31 | LOG_NAME="$(basename $0)" 32 | 33 | source $SCRIPTPATH/utils.sh 34 | 35 | print_args() { 36 | info "Build arguments" 37 | info " BUILD_TYPE: $BUILD_TYPE" 38 | info " SRC_DIR: $SRC_DIR" 39 | info " BUILD_DIR: $BUILD_DIR" 40 | info " INSTALL_PREFIX: $INSTALL_PREFIX" 41 | info "" 42 | } 43 | 44 | print_help() { 45 | echo "" 46 | echo "Usage: build_vaccelrt.sh []" 47 | echo "" 48 | echo "Arguments:" 49 | echo " --release|--debug Type of build (default: debug)" 50 | echo " --src_dir VaccelRT source directory (default: \`\$(pwd)/vaccelrt\`)" 51 | echo " --build_dir Directory to use for out-of-source build (default: 'build')" 52 | echo " --install_prefix Directory to install library (default: 'output')" 53 | echo "" 54 | } 55 | 56 | 57 | prepare_env() { 58 | mkdir -p $BUILD_DIR/vaccelrt 59 | } 60 | 61 | build() { 62 | cd $BUILD_DIR/vaccelrt 63 | # Configure Cmake 64 | cmake $SRC_DIR \ 65 | -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \ 66 | -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ 67 | -DBUILD_EXAMPLES=ON \ 68 | -DBUILD_PLUGIN_NOOP=ON \ 69 | -DENABLE_TESTS=ON 70 | 71 | # Build and install 72 | cmake --build . --config ${BUILD_TYPE} 73 | make test && \ 74 | make install -C src && \ 75 | make install -C plugins && \ 76 | make install -C examples && \ 77 | make install -C third-party 78 | cd - 79 | } 80 | 81 | main() { 82 | while [ $# -gt 0 ]; do 83 | case "$1" in 84 | -h|--help) { print_help; exit 1; };; 85 | --release) { BUILD_TYPE=Release; };; 86 | --debug) { BUILD_TYPE=Debug; };; 87 | --src_dir) { SRC_DIR=$2; shift; };; 88 | --build_dir) { BUILD_DIR=$2; shift; };; 89 | --install_prefix) { INSTALL_PREFIX=$2; shift; };; 90 | *) 91 | die "Unknown argument: \"$1\". Please use \`$0 --help\`." 92 | ;; 93 | esac 94 | shift 95 | done 96 | 97 | print_args 98 | 99 | # Prepare build environment 100 | prepare_env 101 | 102 | # and build 103 | build 104 | } 105 | 106 | main "$@" 107 | -------------------------------------------------------------------------------- /scripts/build_virtio.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # retrieve script path 16 | SCRIPTPATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ) 17 | 18 | # virtio-accel source directory 19 | SRC_DIR="$(pwd)/virtio-accel" 20 | 21 | # build directory 22 | BUILD_DIR="$(pwd)/build" 23 | 24 | # Default installation directory 25 | INSTALL_PREFIX="$(pwd)/output" 26 | 27 | # script name for logging 28 | LOG_NAME="$(basename $0)" 29 | 30 | source $SCRIPTPATH/utils.sh 31 | 32 | print_args() { 33 | info "Build arguments" 34 | info " SRC_DIR: $SRC_DIR" 35 | info " BUILD_DIR: $BUILD_DIR" 36 | info " INSTALL_PREFIX: $INSTALL_PREFIX" 37 | info "" 38 | } 39 | 40 | print_help() { 41 | echo "" 42 | echo "Usage: build_virtio.sh []" 43 | echo "" 44 | echo "Arguments:" 45 | echo " --src_dir VaccelRT source directory (default: \`\$(pwd)/virtio-accel\`)" 46 | echo " --build_dir Directory to use for out-of-source build (default: 'build')" 47 | echo " --install_prefix Directory to install library (default: 'output')" 48 | echo "" 49 | } 50 | 51 | prepare_env() { 52 | sudo apt update && sudo apt install wget 53 | mkdir -p $BUILD_DIR/virtio-accel 54 | mkdir -p $INSTALL_PREFIX/{share,include} 55 | } 56 | 57 | fetch_linux() { 58 | if [ ! -d "linux" ]; then 59 | git clone --depth=1 -b v5.10 https://github.com/torvalds/linux.git 60 | fi 61 | 62 | cd linux 63 | url=$(git remote get-url origin) 64 | echo "$url" 65 | if [ "$url" != "https://github.com/torvalds/linux.git" ]; then 66 | die "Bad linux repo in $(pwd). Remote is $url. Not overwritting" 67 | fi 68 | 69 | git checkout v5.10 70 | } 71 | 72 | build() { 73 | cd $BUILD_DIR/virtio-accel 74 | 75 | # First build the linux kernel 76 | fetch_linux 77 | #cd linux 78 | KERNEL_CONFIG=https://raw.githubusercontent.com/firecracker-microvm/firecracker/main/resources/guest_configs/microvm-kernel-x86_64-5.10.config 79 | wget $KERNEL_CONFIG -O arch/x86/configs/microvm.config 80 | touch .config 81 | make microvm.config CONFIG_MODULES=y 82 | make -j$(nproc) 83 | ok_or_die "Could not build linux kernel" 84 | 85 | # Now build the module 86 | cd .. 87 | make -C $SRC_DIR KDIR=$BUILD_DIR/virtio-accel/linux ZC=0 88 | ok_or_die "Could not build the module" 89 | 90 | cp $SRC_DIR/accel.h $INSTALL_PREFIX/include 91 | cp $SRC_DIR/virtio_accel.ko $BUILD_DIR/virtio-accel/linux/vmlinux $INSTALL_PREFIX/share 92 | } 93 | 94 | main() { 95 | while [ $# -gt 0 ]; do 96 | case "$1" in 97 | -h|--help) { print_help; exit 1; };; 98 | --src_dir) { SRC_DIR=$2; shift; };; 99 | --build_dir) { BUILD_DIR=$2; shift; };; 100 | --install_prefix) { INSTALL_PREFIX=$2; shift; };; 101 | *) 102 | die "Unknown argument: \"$1\". Please use \`$0 --help\`." 103 | ;; 104 | esac 105 | shift 106 | done 107 | 108 | print_args 109 | 110 | # Prepare build environment 111 | prepare_env 112 | 113 | # and build 114 | build 115 | } 116 | 117 | main "$@" 118 | -------------------------------------------------------------------------------- /scripts/build_virtio_plugin.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # retrieve path 16 | SCRIPTPATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ) 17 | 18 | # Default build type 19 | BUILD_TYPE=Debug 20 | 21 | # vaccelrt source directory 22 | SRC_DIR="$(pwd)/plugins/vaccelrt-plugin-virtio" 23 | 24 | # Build directory 25 | BUILD_DIR="$(pwd)/build" 26 | 27 | # Default installation directory 28 | INSTALL_PREFIX="$(pwd)/output" 29 | 30 | # script name for logging 31 | LOG_NAME="$(basename $0)" 32 | 33 | source $SCRIPTPATH/utils.sh 34 | 35 | print_args() { 36 | info "Build arguments" 37 | info " BUILD_TYPE: $BUILD_TYPE" 38 | info " SRC_DIR: $SRC_DIR" 39 | info " BUILD_DIR: $BUILD_DIR" 40 | info " INSTALL_PREFIX: $INSTALL_PREFIX" 41 | info "" 42 | } 43 | 44 | print_help() { 45 | echo "" 46 | echo "Usage: build_vaccelrt.sh []" 47 | echo "" 48 | echo "Arguments:" 49 | echo " --release|--debug Type of build (default: debug)" 50 | echo " --src_dir VaccelRT source directory (default: \`\$(pwd)/vaccelrt\`)" 51 | echo " --build_dir Directory to use for out-of-source build (default: 'build')" 52 | echo " --install_prefix Directory to install library (default: 'output')" 53 | echo "" 54 | } 55 | 56 | 57 | prepare_env() { 58 | mkdir -p $BUILD_DIR/virtio-plugin 59 | } 60 | 61 | build() { 62 | cd $BUILD_DIR/virtio-plugin 63 | # Configure Cmake 64 | cmake $SRC_DIR \ 65 | -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \ 66 | -DCMAKE_BUILD_TYPE=$BUILD_TYPE 67 | ok_or_die "Could not configure cmake" 68 | 69 | # Build and install 70 | cmake --build . --config ${BUILD_TYPE} 71 | ok_or_die "Could not build" 72 | 73 | make install 74 | ok_or_die "Could not install" 75 | 76 | cd - 77 | } 78 | 79 | main() { 80 | while [ $# -gt 0 ]; do 81 | case "$1" in 82 | -h|--help) { print_help; exit 1; };; 83 | --release) { BUILD_TYPE=Release; };; 84 | --debug) { BUILD_TYPE=Debug; };; 85 | --src_dir) { SRC_DIR=$2; shift; };; 86 | --build_dir) { BUILD_DIR=$2; shift; };; 87 | --install_prefix) { INSTALL_PREFIX=$2; shift; };; 88 | *) 89 | die "Unknown argument: \"$1\". Please use \`$0 --help\`." 90 | ;; 91 | esac 92 | shift 93 | done 94 | 95 | print_args 96 | 97 | # Prepare build environment 98 | prepare_env 99 | 100 | # and build 101 | build 102 | } 103 | 104 | main "$@" 105 | -------------------------------------------------------------------------------- /scripts/build_vsock_plugin.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # retrieve path 16 | SCRIPTPATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ) 17 | 18 | # Default build type 19 | BUILD_TYPE=Debug 20 | 21 | # plugin source directory 22 | SRC_DIR="$(pwd)/plugins/vaccelrt-plugin-vsock" 23 | 24 | # Build directory 25 | BUILD_DIR="$(pwd)/build" 26 | 27 | # Default installation directory 28 | INSTALL_PREFIX="$(pwd)/output" 29 | 30 | # script name for logging 31 | LOG_NAME="$(basename $0)" 32 | 33 | source $SCRIPTPATH/utils.sh 34 | 35 | print_args() { 36 | info "Build arguments" 37 | info " BUILD_TYPE: $BUILD_TYPE" 38 | info " SRC_DIR: $SRC_DIR" 39 | info " BUILD_DIR: $BUILD_DIR" 40 | info " INSTALL_PREFIX: $INSTALL_PREFIX" 41 | info "" 42 | } 43 | 44 | print_help() { 45 | echo "" 46 | echo "Usage: build_vsock_plugin.sh []" 47 | echo "" 48 | echo "Arguments:" 49 | echo " --release|--debug Type of build (default: debug)" 50 | echo " --src_dir TensorFlow plugin source directory (default: \`\$(pwd)/plugins/vaccelrt-plugin-vsock\`)" 51 | echo " --build_dir Directory to use for out-of-source build (default: 'build')" 52 | echo " --install_prefix Directory to install library (default: 'output')" 53 | echo "" 54 | } 55 | 56 | 57 | prepare_env() { 58 | mkdir -p $BUILD_DIR/vsock-plugin 59 | info "Build directory: $BUILD_DIR/vsock-plugin" 60 | } 61 | 62 | build() { 63 | cd $BUILD_DIR/vsock-plugin 64 | # Configure Cmake 65 | cmake $SRC_DIR \ 66 | -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \ 67 | -DCMAKE_BUILD_TYPE=$BUILD_TYPE 68 | ok_or_die "Could not configure cmake" 69 | 70 | # Build and install 71 | cmake --build . --config ${BUILD_TYPE} 72 | ok_or_die "Could not build" 73 | 74 | make install 75 | ok_or_die "Could not install" 76 | 77 | cd - 78 | } 79 | 80 | main() { 81 | while [ $# -gt 0 ]; do 82 | case "$1" in 83 | -h|--help) { print_help; exit 1; };; 84 | --release) { BUILD_TYPE=Release; };; 85 | --debug) { BUILD_TYPE=Debug; };; 86 | --src_dir) { SRC_DIR=$2; shift; };; 87 | --build_dir) { BUILD_DIR=$2; shift; };; 88 | --install_prefix) { INSTALL_PREFIX=$2; shift; };; 89 | *) 90 | die "Unknown argument: \"$1\". Please use \`$0 --help\`." 91 | ;; 92 | esac 93 | shift 94 | done 95 | 96 | print_args 97 | 98 | # Prepare build environment 99 | prepare_env 100 | 101 | # and build 102 | build 103 | } 104 | 105 | main "$@" 106 | -------------------------------------------------------------------------------- /scripts/create_tap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | if [[ $# -ne 2 ]] ; then 16 | echo "usage $0 tapName address/prefix" 17 | exit 1 18 | fi 19 | 20 | tap_name=$1 21 | addr=$2 22 | 23 | ip tuntap add ${tap_name} mode tap 24 | ip addr add dev ${tap_name} ${addr} 25 | ip link set dev ${tap_name} up 26 | -------------------------------------------------------------------------------- /scripts/download-models.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a 6 | # copy of this software and associated documentation files (the "Software"), 7 | # to deal in the Software without restriction, including without limitation 8 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | # and/or sell copies of the Software, and to permit persons to whom the 10 | # Software is furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | # DEALINGS IN THE SOFTWARE. 22 | # 23 | 24 | APP_TITLE="Hello AI World (jetson-inference)" 25 | OUTPUT_DIR=${2:-"output/networks"} 26 | LOG="[jetson-inference] " 27 | WGET_QUIET="--quiet" 28 | BUILD_INTERACTIVE=${1:-"YES"} 29 | 30 | 31 | mkdir -p ${OUTPUT_DIR} 32 | 33 | # 34 | # exit message for user 35 | # 36 | function exit_message() 37 | { 38 | echo " " 39 | echo "$LOG to run this tool again, use the following commands:" 40 | echo " " 41 | echo " $ cd /tools" 42 | echo " $ ./download-models.sh" 43 | echo " " 44 | 45 | exit $1 46 | } 47 | 48 | # 49 | # prompt user for retry 50 | # 51 | function retry_prompt() 52 | { 53 | dialog --backtitle "$APP_TITLE" \ 54 | --title "Download Error" \ 55 | --colors \ 56 | --extra-button \ 57 | --extra-label "Next" \ 58 | --cancel-label "Quit" \ 59 | --ok-label "Retry" \ 60 | --yesno "\nFailed to download '$1' (error code=$2)\n\nWould you like to try downloading it again?\n\n\ZbNote:\Zn if this error keeps occuring, see here:\n https://github.com/dusty-nv/jetson-inference/releases" 12 60 61 | 62 | local retry_status=$? 63 | clear 64 | 65 | WGET_QUIET="--verbose" 66 | 67 | if [ $retry_status = 1 ]; then 68 | echo "$LOG models failed to download (they may not load at runtime)" 69 | exit_message 1 70 | elif [ $retry_status != 0 ]; then 71 | return 1 72 | fi 73 | 74 | return 0 75 | } 76 | 77 | 78 | # 79 | # try to download a file from URL 80 | # 81 | function attempt_download_file() 82 | { 83 | local filename=$1 84 | local URL=$2 85 | 86 | wget $WGET_QUIET --show-progress --progress=bar:force:noscroll --no-check-certificate $URL -O $filename 87 | 88 | local wget_status=$? 89 | 90 | if [ $wget_status != 0 ]; then 91 | echo "$LOG wget failed to download '$filename' (error code=$wget_status)" 92 | return $wget_status 93 | fi 94 | 95 | mv $filename $OUTPUT_DIR 96 | return 0 97 | } 98 | 99 | 100 | # 101 | # download a file from URL 102 | # 103 | function download_file() 104 | { 105 | local filename=$1 106 | local URL=$2 107 | 108 | WGET_QUIET="--quiet" 109 | 110 | while true; do 111 | attempt_download_file $filename $URL 112 | 113 | local download_status=$? 114 | 115 | if [ $download_status = 0 ]; then 116 | return 0 117 | fi 118 | 119 | retry_prompt $filename $download_status 120 | 121 | local retry_status=$? 122 | 123 | if [ $retry_status != 0 ]; then 124 | return 0 125 | fi 126 | done 127 | } 128 | 129 | 130 | # 131 | # try to download/extract an archive 132 | # 133 | function attempt_download_archive() 134 | { 135 | local filename=$1 136 | local URL=$2 137 | 138 | wget $WGET_QUIET --show-progress --progress=bar:force:noscroll --no-check-certificate $URL -O $filename 139 | 140 | local wget_status=$? 141 | 142 | if [ $wget_status != 0 ]; then 143 | echo "$LOG wget failed to download '$filename' (error code=$wget_status)" 144 | return $wget_status 145 | fi 146 | 147 | tar -xzf $filename -C $OUTPUT_DIR 148 | 149 | local tar_status=$? 150 | 151 | if [ $tar_status != 0 ]; then 152 | echo "$LOG tar failed to extract '$filename' (error code=$tar_status)" 153 | return $tar_status 154 | fi 155 | 156 | rm $filename 157 | return 0 158 | } 159 | 160 | 161 | # 162 | # download/extract an archive 163 | # 164 | function download_archive() 165 | { 166 | local filename=$1 167 | local URL=$2 168 | 169 | WGET_QUIET="--quiet" 170 | 171 | while true; do 172 | attempt_download_archive $filename $URL 173 | 174 | local download_status=$? 175 | 176 | if [ $download_status = 0 ]; then 177 | return 0 178 | fi 179 | 180 | retry_prompt $filename $download_status 181 | 182 | local retry_status=$? 183 | 184 | if [ $retry_status != 0 ]; then 185 | return 0 186 | fi 187 | done 188 | } 189 | 190 | # 191 | # IMAGE RECOGNITION 192 | # 193 | function download_alexnet() 194 | { 195 | echo "$LOG Downloading AlexNet..." 196 | 197 | download_file "bvlc_alexnet.caffemodel" "https://nvidia.box.com/shared/static/5j264j7mky11q8emy4q14w3r8hl5v6zh.caffemodel" 198 | download_file "alexnet.prototxt" "https://nvidia.box.com/shared/static/c84wp3axbtv4e2gybn40jprdquav9azm.prototxt" 199 | download_file "alexnet_noprob.prototxt" "https://nvidia.box.com/shared/static/o0w0sl3obqxj21u09c0cwzw4khymz7hh.prototxt" 200 | } 201 | 202 | function download_googlenet() 203 | { 204 | echo "$LOG Downloading GoogleNet..." 205 | 206 | download_file "bvlc_googlenet.caffemodel" "https://nvidia.box.com/shared/static/at8b1105ww1c5h7p30j5ko8qfnxrs0eg.caffemodel" 207 | download_file "googlenet.prototxt" "https://nvidia.box.com/shared/static/5z3l76p8ap4n0o6rk7lyasdog9f14gc7.prototxt" 208 | download_file "googlenet_noprob.prototxt" "https://nvidia.box.com/shared/static/ue8qrqtglu36andbvobvaaj8egxjaoli.prototxt" 209 | } 210 | 211 | function download_googlenet12() 212 | { 213 | echo "$LOG Downloading GoogleNet-12..." 214 | download_archive "GoogleNet-ILSVRC12-subset.tar.gz" "https://nvidia.box.com/shared/static/zb8i3zcg39sdjjxfty7o5935hpbd64y4.gz" 215 | } 216 | 217 | function download_resnet18() 218 | { 219 | echo "$LOG Downloading ResNet-18..." 220 | download_archive "ResNet-18.tar.gz" "https://nvidia.box.com/shared/static/gph1qfor89vh498op8cicvwc13zltu3h.gz" 221 | } 222 | 223 | function download_resnet50() 224 | { 225 | echo "$LOG Downloading ResNet-50..." 226 | download_archive "ResNet-50.tar.gz" "https://nvidia.box.com/shared/static/ht46fmnwvow0o0n0ke92x6bzkht8g5xb.gz" 227 | } 228 | 229 | function download_resnet101() 230 | { 231 | echo "$LOG Downloading ResNet-101..." 232 | download_archive "ResNet-101.tar.gz" "https://nvidia.box.com/shared/static/7zog25pu70nxjh2irni49e5ujlg4dl82.gz" 233 | } 234 | 235 | function download_resnet152() 236 | { 237 | echo "$LOG Downloading ResNet-152..." 238 | download_archive "ResNet-152.tar.gz" "https://nvidia.box.com/shared/static/6t621ru1i054vscvhx3rqck8597es7w8.gz" 239 | } 240 | 241 | function download_vgg16() 242 | { 243 | echo "$LOG Downloading VGG-16..." 244 | download_archive "VGG-16.tar.gz" "https://nvidia.box.com/shared/static/ar2ttdpnw1drzxnvpw0umzkw67fka3h0.gz" 245 | } 246 | 247 | function download_vgg19() 248 | { 249 | echo "$LOG Downloading VGG-19..." 250 | download_archive "VGG-19.tar.gz" "https://nvidia.box.com/shared/static/1ubk73f1akhh4h7mo0iq7erars7j5yyu.gz" 251 | } 252 | 253 | function download_inception_v4() 254 | { 255 | echo "$LOG Downloading Inception-v4..." 256 | download_archive "Inception-v4.tar.gz" "https://nvidia.box.com/shared/static/maidbjiwkg6bz2bk7drwq7rj8v4whdl9.gz" 257 | } 258 | 259 | function download_recognition() 260 | { 261 | echo "$LOG Downloading all Image Recognition models..." 262 | 263 | download_alexnet 264 | 265 | download_googlenet 266 | download_googlenet12 267 | 268 | download_resnet18 269 | download_resnet50 270 | download_resnet101 271 | download_resnet152 272 | 273 | download_vgg16 274 | download_vgg19 275 | 276 | download_inception_v4 277 | 278 | ALL_RECOGNITION=1 279 | } 280 | 281 | 282 | # 283 | # OBJECT DETECTION 284 | # 285 | function download_pednet() 286 | { 287 | echo "$LOG Downloading PedNet..." 288 | download_archive "ped-100.tar.gz" "https://nvidia.box.com/shared/static/0wbxo6lmxfamm1dk90l8uewmmbpbcffb.gz" 289 | } 290 | 291 | function download_multiped() 292 | { 293 | echo "$LOG Downloading MultiPed..." 294 | download_archive "multiped-500.tar.gz" "https://nvidia.box.com/shared/static/r3bq08qh7zb0ap2lf4ysjujdx64j8ofw.gz" 295 | } 296 | 297 | function download_facenet() 298 | { 299 | echo "$LOG Downloading FaceNet..." 300 | download_archive "facenet-120.tar.gz" "https://nvidia.box.com/shared/static/wjitc00ef8j6shjilffibm6r2xxcpigz.gz" 301 | } 302 | 303 | function download_detectnet_coco_dog() 304 | { 305 | echo "$LOG Downloading DetectNet-COCO-Dog..." 306 | download_archive "DetectNet-COCO-Dog.tar.gz" "https://nvidia.box.com/shared/static/3qdg3z5qvl8iwjlds6bw7bwi2laloytu.gz" 307 | } 308 | 309 | function download_detectnet_coco_chair() 310 | { 311 | echo "$LOG Downloading DetectNet-COCO-Chair..." 312 | download_archive "DetectNet-COCO-Chair.tar.gz" "https://nvidia.box.com/shared/static/fq0m0en5mmssiizhs9nxw3xtwgnoltf2.gz" 313 | } 314 | 315 | function download_detectnet_coco_bottle() 316 | { 317 | echo "$LOG Downloading DetectNet-COCO-Bottle..." 318 | download_archive "DetectNet-COCO-Bottle.tar.gz" "https://nvidia.box.com/shared/static/8bhm91o9yldpf97dcz5d0welgmjy7ucw.gz" 319 | } 320 | 321 | function download_detectnet_coco_airplane() 322 | { 323 | echo "$LOG Downloading DetectNet-COCO-Airplane..." 324 | download_archive "DetectNet-COCO-Airplane.tar.gz" "https://nvidia.box.com/shared/static/xi71hlsht5b0y66loeg73rxfa73q561s.gz" 325 | } 326 | 327 | function download_ssd_mobilenet_v1() 328 | { 329 | echo "$LOG Downloading SSD-Mobilenet-v1..." 330 | download_archive "SSD-Mobilenet-v1.tar.gz" "https://nvidia.box.com/shared/static/0pg3xi9opwio65df14rdgrtw40ivbk1o.gz" 331 | } 332 | 333 | function download_ssd_mobilenet_v2() 334 | { 335 | echo "$LOG Downloading SSD-Mobilenet-v2..." 336 | download_archive "SSD-Mobilenet-v2.tar.gz" "https://nvidia.box.com/shared/static/jcdewxep8vamzm71zajcovza938lygre.gz" 337 | } 338 | 339 | function download_ssd_inception_v2() 340 | { 341 | echo "$LOG Downloading SSD-Inception-v2..." 342 | download_archive "SSD-Inception-v2.tar.gz" "https://nvidia.box.com/shared/static/mjq1cel6r5mdk94yb9o6v4nj8gxzlflr.gz" 343 | } 344 | 345 | function download_detection() 346 | { 347 | echo "$LOG Downloading all Object Detection models..." 348 | 349 | download_ssd_mobilenet_v1 350 | download_ssd_mobilenet_v2 351 | download_ssd_inception_v2 352 | 353 | download_pednet 354 | download_multiped 355 | download_facenet 356 | 357 | download_detectnet_coco_dog 358 | download_detectnet_coco_bottle 359 | download_detectnet_coco_chair 360 | download_detectnet_coco_airplane 361 | 362 | ALL_DETECTION=1 363 | } 364 | 365 | 366 | # 367 | # SEMANTIC SEGMENTATION 368 | # 369 | function download_fcn_resnet18_cityscapes_512x256() 370 | { 371 | echo "$LOG Downloading FCN-ResNet18-Cityscapes-512x256..." 372 | download_archive "FCN-ResNet18-Cityscapes-512x256.tar.gz" "https://nvidia.box.com/shared/static/k7s7gdgi098309fndm2xbssj553vf71s.gz" 373 | } 374 | 375 | function download_fcn_resnet18_cityscapes_1024x512() 376 | { 377 | echo "$LOG Downloading FCN-ResNet18-Cityscapes-1024x512..." 378 | download_archive "FCN-ResNet18-Cityscapes-1024x512.tar.gz" "https://nvidia.box.com/shared/static/9aqg4gpjmk7ipz4z0raa5mvs35om6emy.gz" 379 | } 380 | 381 | function download_fcn_resnet18_cityscapes_2048x1024() 382 | { 383 | echo "$LOG Downloading FCN-ResNet18-Cityscapes-2048x1024..." 384 | download_archive "FCN-ResNet18-Cityscapes-2048x1024.tar.gz" "https://nvidia.box.com/shared/static/ylh3d2qk8qvitalq8sy803o7avrb6w0h.gz" 385 | } 386 | 387 | function download_fcn_resnet18_deepscene_576x320() 388 | { 389 | echo "$LOG Downloading FCN-ResNet18-DeepScene-576x320..." 390 | download_archive "FCN-ResNet18-DeepScene-576x320.tar.gz" "https://nvidia.box.com/shared/static/jm0zlezvweiimpzluohg6453s0u0nvcv.gz" 391 | } 392 | 393 | function download_fcn_resnet18_deepscene_864x480() 394 | { 395 | echo "$LOG Downloading FCN-ResNet18-DeepScene-864x480..." 396 | download_archive "FCN-ResNet18-DeepScene-864x480.tar.gz" "https://nvidia.box.com/shared/static/gooux9b5nknk8wlk60ou9s2unpo760iq.gz" 397 | } 398 | 399 | function download_fcn_resnet18_mhp_512x320() 400 | { 401 | echo "$LOG Downloading FCN-ResNet18-MHP-512x320..." 402 | download_archive "FCN-ResNet18-MHP-512x320.tar.gz" "https://nvidia.box.com/shared/static/dgaw0ave3bdws1t5ed333ftx5dbpt9zv.gz" 403 | } 404 | 405 | function download_fcn_resnet18_mhp_640x360() 406 | { 407 | echo "$LOG Downloading FCN-ResNet18-MHP-640x360..." 408 | download_archive "FCN-ResNet18-MHP-640x360.tar.gz" "https://nvidia.box.com/shared/static/50mvlrjwbq9ugkmnnqp1sm99g2j21sfn.gz" 409 | } 410 | 411 | function download_fcn_resnet18_pascal_voc_320x320() 412 | { 413 | echo "$LOG Downloading FCN-ResNet18-Pascal-VOC-320x320..." 414 | download_archive "FCN-ResNet18-Pascal-VOC-320x320.tar.gz" "https://nvidia.box.com/shared/static/p63pgrr6tm33tn23913gq6qvaiarydaj.gz" 415 | } 416 | 417 | function download_fcn_resnet18_pascal_voc_512x320() 418 | { 419 | echo "$LOG Downloading FCN-ResNet18-Pascal-VOC-512x320..." 420 | download_archive "FCN-ResNet18-Pascal-VOC-512x320.tar.gz" "https://nvidia.box.com/shared/static/njup7f3vu4mgju89kfre98olwljws5pk.gz" 421 | } 422 | 423 | function download_fcn_resnet18_sun_rgbd_512x400() 424 | { 425 | echo "$LOG Downloading FCN-ResNet18-SUN-RGBD-512x400..." 426 | download_archive "FCN-ResNet18-SUN-RGBD-512x400.tar.gz" "https://nvidia.box.com/shared/static/5vs9t2wah5axav11k8o3l9skb7yy3xgd.gz" 427 | } 428 | 429 | function download_fcn_resnet18_sun_rgbd_640x512() 430 | { 431 | echo "$LOG Downloading FCN-ResNet18-SUN-RGBD-640x512..." 432 | download_archive "FCN-ResNet18-SUN-RGBD-640x512.tar.gz" "https://nvidia.box.com/shared/static/z5llxysbcqd8zzzsm7vjqeihs7ihdw20.gz" 433 | } 434 | 435 | function download_segmentation() 436 | { 437 | echo "$LOG Downloading all Semantic Segmentation models..." 438 | 439 | download_fcn_resnet18_cityscapes_512x256 440 | download_fcn_resnet18_cityscapes_1024x512 441 | download_fcn_resnet18_cityscapes_2048x1024 442 | download_fcn_resnet18_deepscene_576x320 443 | download_fcn_resnet18_deepscene_864x480 444 | download_fcn_resnet18_mhp_512x320 445 | download_fcn_resnet18_mhp_640x360 446 | download_fcn_resnet18_pascal_voc_320x320 447 | download_fcn_resnet18_pascal_voc_512x320 448 | download_fcn_resnet18_sun_rgbd_512x400 449 | download_fcn_resnet18_sun_rgbd_640x512 450 | 451 | ALL_SEGMENTATION=1 452 | } 453 | 454 | 455 | # 456 | # SEMANTIC SEGMENTATION (legacy) 457 | # 458 | function download_fcn_alexnet_cityscapes_sd() 459 | { 460 | echo "$LOG Downloading FCN-Alexnet-Cityscapes-SD..." 461 | download_archive "FCN-Alexnet-Cityscapes-SD.tar.gz" "https://nvidia.box.com/shared/static/pa5d338t9ntca5chfbymnur53aykhall.gz" 462 | } 463 | 464 | function download_fcn_alexnet_cityscapes_hd() 465 | { 466 | echo "$LOG Downloading FCN-Alexnet-Cityscapes-HD..." 467 | download_archive "FCN-Alexnet-Cityscapes-HD.tar.gz" "https://nvidia.box.com/shared/static/mh121fvmveemujut7d8c9cbmglq18vz3.gz" 468 | } 469 | 470 | function download_fcn_alexnet_aerial_fpv() 471 | { 472 | echo "$LOG Downloading FCN-Alexnet-Aerial-FPV..." 473 | download_archive "FCN-Alexnet-Aerial-FPV-720p.tar.gz" "https://nvidia.box.com/shared/static/y1mzlwkmytzwg2m7akt7tcbsd33f9opz.gz" 474 | } 475 | 476 | function download_fcn_alexnet_pascal_voc() 477 | { 478 | echo "$LOG Downloading FCN-Alexnet-Pascal-VOC..." 479 | download_archive "FCN-Alexnet-Pascal-VOC.tar.gz" "https://nvidia.box.com/shared/static/xj20b6qopfwkkpqm12ffiuaekk6bs8op.gz" 480 | } 481 | 482 | function download_fcn_alexnet_synthia_cvpr() 483 | { 484 | echo "$LOG Downloading FCN-Alexnet-Synthia-CVPR..." 485 | download_archive "FCN-Alexnet-SYNTHIA-CVPR16.tar.gz" "https://nvidia.box.com/shared/static/u5ey2ws0nbtzyqyftkuqazx1honw6wry.gz" 486 | } 487 | 488 | function download_fcn_alexnet_synthia_summer_sd() 489 | { 490 | echo "$LOG Downloading FCN-Alexnet-Synthia-Summer-SD..." 491 | download_archive "FCN-Alexnet-SYNTHIA-Summer-SD.tar.gz" "https://nvidia.box.com/shared/static/vbk5ofu1x2hwp9luanbg4o0vrfub3a7j.gz" 492 | } 493 | 494 | function download_fcn_alexnet_synthia_summer_hd() 495 | { 496 | echo "$LOG Downloading FCN-Alexnet-Synthia-Summer-HD..." 497 | download_archive "FCN-Alexnet-SYNTHIA-Summer-HD.tar.gz" "https://nvidia.box.com/shared/static/ydgmqgdhbvul6q9avoc9flxr3fdoa8pw.gz" 498 | } 499 | 500 | function download_segmentation_legacy() 501 | { 502 | echo "$LOG Downloading all Semantic Segmentation (Legacy) models..." 503 | 504 | download_fcn_alexnet_cityscapes_sd 505 | download_fcn_alexnet_cityscapes_hd 506 | download_fcn_alexnet_aerial_fpv 507 | download_fcn_alexnet_pascal_voc 508 | download_fcn_alexnet_synthia_cvpr 509 | download_fcn_alexnet_synthia_summer_sd 510 | download_fcn_alexnet_synthia_summer_hd 511 | 512 | ALL_SEGMENTATION_LEGACY=1 513 | } 514 | 515 | 516 | # 517 | # IMAGE PROCESSING 518 | # 519 | function download_deep_homography_coco() 520 | { 521 | echo "$LOG Downloading Deep-Homography-COCO..." 522 | download_archive "Deep-Homography-COCO.tar.gz" "https://nvidia.box.com/shared/static/nlqbsdnt76y0nmkwdzxkg4zbvhk4bidh.gz" 523 | } 524 | 525 | function download_super_resolution_bsd500() 526 | { 527 | echo "$LOG Downloading Super-Resolution-BSD500..." 528 | download_archive "Super-Resolution-BSD500.tar.gz" "https://nvidia.box.com/shared/static/a99l8ttk21p3tubjbyhfn4gh37o45rn8.gz" 529 | } 530 | 531 | function download_image_processing() 532 | { 533 | echo "$LOG Downloading all Image Processing models..." 534 | 535 | download_deep_homography_coco 536 | download_super_resolution_bsd500 537 | 538 | ALL_IMAGE_PROCESSING=1 539 | } 540 | 541 | 542 | # 543 | # check if a particular deb package is installed with dpkg-query 544 | # arg $1 -> package name 545 | # arg $2 -> variable name to output status to (e.g. HAS_PACKAGE=1) 546 | # 547 | function find_deb_package() 548 | { 549 | local PKG_NAME=$1 550 | local HAS_PKG=`dpkg-query -W --showformat='${Status}\n' $PKG_NAME|grep "install ok installed"` 551 | 552 | if [ "$HAS_PKG" == "" ]; then 553 | echo "$LOG Checking for '$PKG_NAME' deb package...not installed" 554 | else 555 | echo "$LOG Checking for '$PKG_NAME' deb package...installed" 556 | eval "$2=INSTALLED" 557 | fi 558 | } 559 | 560 | 561 | # 562 | # install a debian package if it isn't already installed 563 | # arg $1 -> package name 564 | # arg $2 -> variable name to output status to (e.g. FOUND_PACKAGE=INSTALLED) 565 | # 566 | function install_deb_package() 567 | { 568 | local PKG_NAME=$1 569 | 570 | # check to see if the package is already installed 571 | find_deb_package $PKG_NAME $2 572 | 573 | # if not, install the package 574 | if [ -z $2 ]; then 575 | echo "$LOG Missing '$PKG_NAME' deb package...installing '$PKG_NAME' package." 576 | sudo apt-get --force-yes --yes install $PKG_NAME 577 | else 578 | return 0 579 | fi 580 | 581 | # verify that the package was installed 582 | find_deb_package $PKG_NAME $2 583 | 584 | if [ -z $2 ]; then 585 | echo "$LOG Failed to install '$PKG_NAME' deb package." 586 | return 1 587 | else 588 | echo "$LOG Successfully installed '$PKG_NAME' deb package." 589 | return 0 590 | fi 591 | } 592 | 593 | 594 | # 595 | # non-interactive mode 596 | # 597 | echo "$LOG BUILD_INTERACTVE=$BUILD_INTERACTIVE" 598 | 599 | if [[ "$BUILD_INTERACTIVE" != "YES" ]]; then 600 | 601 | echo "$LOG Downloading default models..." 602 | 603 | download_googlenet 604 | # download_resnet18 605 | 606 | # download_ssd_mobilenet_v2 607 | # download_pednet 608 | # download_facenet 609 | # download_detectnet_coco_dog 610 | 611 | # download_fcn_resnet18_cityscapes_512x256 612 | # download_fcn_resnet18_cityscapes_1024x512 613 | # download_fcn_resnet18_deepscene_576x320 614 | # download_fcn_resnet18_mhp_512x320 615 | # download_fcn_resnet18_pascal_voc_320x320 616 | # download_fcn_resnet18_sun_rgbd_512x400 617 | 618 | exit_message 0 619 | fi 620 | 621 | 622 | # check for dialog package 623 | install_deb_package "dialog" FOUND_DIALOG 624 | echo "$LOG FOUND_DIALOG=$FOUND_DIALOG" 625 | 626 | # use customized RC config 627 | export DIALOGRC=./download-models.rc 628 | 629 | 630 | # 631 | # main menu 632 | # 633 | while true; do 634 | 635 | models_selected=$(dialog --backtitle "$APP_TITLE" \ 636 | --title "Model Downloader" \ 637 | --cancel-label "Quit" \ 638 | --colors \ 639 | --checklist "Keys:\n ↑↓ Navigate Menu\n Space to Select Models \n Enter to Continue" 20 80 10 \ 640 | --output-fd 1 \ 641 | 1 "\ZbImage Recognition - all models (2.2 GB)\Zn" off \ 642 | 2 " > AlexNet (244 MB)" off \ 643 | 3 " > GoogleNet (54 MB)" on \ 644 | 4 " > GoogleNet-12 (42 MB)" off \ 645 | 5 " > ResNet-18 (47 MB)" on \ 646 | 6 " > ResNet-50 (102 MB)" off \ 647 | 7 " > ResNet-101 (179 MB)" off \ 648 | 8 " > ResNet-152 (242 MB)" off \ 649 | 9 " > VGG-16 (554 MB)" off \ 650 | 10 " > VGG-19 (575 MB)" off \ 651 | 11 " > Inception-v4 (172 MB)" off \ 652 | 12 "\ZbObject Detection - all models (395 MB)\Zn" off \ 653 | 13 " > SSD-Mobilenet-v1 (27 MB)" off \ 654 | 14 " > SSD-Mobilenet-v2 (68 MB)" on \ 655 | 15 " > SSD-Inception-v2 (100 MB)" off \ 656 | 16 " > PedNet (30 MB)" on \ 657 | 17 " > MultiPed (30 MB)" off \ 658 | 18 " > FaceNet (24 MB)" on \ 659 | 19 " > DetectNet-COCO-Dog (29 MB)" on \ 660 | 20 " > DetectNet-COCO-Bottle (29 MB)" off \ 661 | 21 " > DetectNet-COCO-Chair (29 MB)" off \ 662 | 22 " > DetectNet-COCO-Airplane (29 MB)" off \ 663 | 23 "\ZbSemantic Segmentation - all (518 MB)\Zn" off \ 664 | 24 " > FCN-ResNet18-Cityscapes-512x256 (47 MB)" on \ 665 | 25 " > FCN-ResNet18-Cityscapes-1024x512 (47 MB)" on \ 666 | 26 " > FCN-ResNet18-Cityscapes-2048x1024 (47 MB)" off \ 667 | 27 " > FCN-ResNet18-DeepScene-576x320 (47 MB)" on \ 668 | 28 " > FCN-ResNet18-DeepScene-864x480 (47 MB)" off \ 669 | 29 " > FCN-ResNet18-MHP-512x320 (47 MB)" on \ 670 | 30 " > FCN-ResNet18-MHP-640x360 (47 MB)" off \ 671 | 31 " > FCN-ResNet18-Pascal-VOC-320x320 (47 MB)" on \ 672 | 32 " > FCN-ResNet18-Pascal-VOC-512x320 (47 MB)" off \ 673 | 33 " > FCN-ResNet18-SUN-RGBD-512x400 (47 MB)" on \ 674 | 34 " > FCN-ResNet18-SUN-RGBD-640x512 (47 MB)" off \ 675 | 35 "\ZbSemantic Segmentation - legacy (1.4 GB)\Zn" off \ 676 | 36 " > FCN-Alexnet-Cityscapes-SD (235 MB)" off \ 677 | 37 " > FCN-Alexnet-Cityscapes-HD (235 MB)" off \ 678 | 38 " > FCN-Alexnet-Aerial-FPV (7 MB)" off \ 679 | 39 " > FCN-Alexnet-Pascal-VOC (235 MB)" off \ 680 | 40 " > FCN-Alexnet-Synthia-CVPR (235 MB)" off \ 681 | 41 " > FCN-Alexnet-Synthia-Summer-SD (235 MB)" off \ 682 | 42 " > FCN-Alexnet-Synthia-Summer-HD (235 MB)" off \ 683 | 43 "\ZbImage Processing - all models (138 MB)\Zn" off \ 684 | 44 " > Deep-Homography-COCO (137 MB)" off \ 685 | 45 " > Super-Resolution-BSD500 (1 MB)" off ) 686 | 687 | model_selection_status=$? 688 | clear 689 | 690 | echo "$LOG Model selection status: $model_selection_status" 691 | 692 | if [ $model_selection_status = 0 ]; then 693 | 694 | if [ -z "$models_selected" ]; then 695 | echo "$LOG No models were selected for download." 696 | else 697 | echo "$LOG Models selected for download: $models_selected" 698 | 699 | for model in $models_selected 700 | do 701 | if [ $model = 1 ]; then 702 | download_recognition 703 | elif [ $model = 2 ] && [ -z $ALL_RECOGNITION ]; then 704 | download_alexnet 705 | elif [ $model = 3 ] && [ -z $ALL_RECOGNITION ]; then 706 | download_googlenet 707 | elif [ $model = 4 ] && [ -z $ALL_RECOGNITION ]; then 708 | download_googlenet12 709 | elif [ $model = 5 ] && [ -z $ALL_RECOGNITION ]; then 710 | download_resnet18 711 | elif [ $model = 6 ] && [ -z $ALL_RECOGNITION ]; then 712 | download_resnet50 713 | elif [ $model = 7 ] && [ -z $ALL_RECOGNITION ]; then 714 | download_resnet101 715 | elif [ $model = 8 ] && [ -z $ALL_RECOGNITION ]; then 716 | download_resnet152 717 | elif [ $model = 9 ] && [ -z $ALL_RECOGNITION ]; then 718 | download_vgg16 719 | elif [ $model = 10 ] && [ -z $ALL_RECOGNITION ]; then 720 | download_vgg19 721 | elif [ $model = 8 ] && [ -z $ALL_RECOGNITION ]; then 722 | download_inception_v4 723 | elif [ $model = 12 ]; then 724 | download_detection 725 | elif [ $model = 13 ] && [ -z $ALL_DETECTION ]; then 726 | download_ssd_mobilenet_v1 727 | elif [ $model = 14 ] && [ -z $ALL_DETECTION ]; then 728 | download_ssd_mobilenet_v2 729 | elif [ $model = 15 ] && [ -z $ALL_DETECTION ]; then 730 | download_ssd_inception_v2 731 | elif [ $model = 16 ] && [ -z $ALL_DETECTION ]; then 732 | download_pednet 733 | elif [ $model = 17 ] && [ -z $ALL_DETECTION ]; then 734 | download_multiped 735 | elif [ $model = 18 ] && [ -z $ALL_DETECTION ]; then 736 | download_facenet 737 | elif [ $model = 19 ] && [ -z $ALL_DETECTION ]; then 738 | download_detectnet_coco_dog 739 | elif [ $model = 20 ] && [ -z $ALL_DETECTION ]; then 740 | download_detectnet_coco_bottle 741 | elif [ $model = 21 ] && [ -z $ALL_DETECTION ]; then 742 | download_detectnet_coco_chair 743 | elif [ $model = 22 ] && [ -z $ALL_DETECTION ]; then 744 | download_detectnet_coco_airplane 745 | elif [ $model = 23 ]; then 746 | download_segmentation 747 | elif [ $model = 24 ] && [ -z $ALL_SEGMENTATION ]; then 748 | download_fcn_resnet18_cityscapes_512x256 749 | elif [ $model = 25 ] && [ -z $ALL_SEGMENTATION ]; then 750 | download_fcn_resnet18_cityscapes_1024x512 751 | elif [ $model = 26 ] && [ -z $ALL_SEGMENTATION ]; then 752 | download_fcn_resnet18_cityscapes_2048x1024 753 | elif [ $model = 27 ] && [ -z $ALL_SEGMENTATION ]; then 754 | download_fcn_resnet18_deepscene_576x320 755 | elif [ $model = 28 ] && [ -z $ALL_SEGMENTATION ]; then 756 | download_fcn_resnet18_deepscene_864x480 757 | elif [ $model = 29 ] && [ -z $ALL_SEGMENTATION ]; then 758 | download_fcn_resnet18_mhp_512x320 759 | elif [ $model = 30 ] && [ -z $ALL_SEGMENTATION ]; then 760 | download_fcn_resnet18_mhp_640x360 761 | elif [ $model = 31 ] && [ -z $ALL_SEGMENTATION ]; then 762 | download_fcn_resnet18_pascal_voc_320x320 763 | elif [ $model = 32 ] && [ -z $ALL_SEGMENTATION ]; then 764 | download_fcn_resnet18_pascal_voc_512x320 765 | elif [ $model = 33 ] && [ -z $ALL_SEGMENTATION ]; then 766 | download_fcn_resnet18_sun_rgbd_512x400 767 | elif [ $model = 34 ] && [ -z $ALL_SEGMENTATION ]; then 768 | download_fcn_resnet18_sun_rgbd_640x512 769 | elif [ $model = 35 ]; then 770 | download_segmentation_legacy 771 | elif [ $model = 36 ] && [ -z $ALL_SEGMENTATION_LEGACY ]; then 772 | download_fcn_alexnet_cityscapes_sd 773 | elif [ $model = 37 ] && [ -z $ALL_SEGMENTATION_LEGACY ]; then 774 | download_fcn_alexnet_cityscapes_hd 775 | elif [ $model = 38 ] && [ -z $ALL_SEGMENTATION_LEGACY ]; then 776 | download_fcn_alexnet_aerial_fpv 777 | elif [ $model = 39 ] && [ -z $ALL_SEGMENTATION_LEGACY ]; then 778 | download_fcn_alexnet_pascal_voc 779 | elif [ $model = 40 ] && [ -z $ALL_SEGMENTATION_LEGACY ]; then 780 | download_fcn_alexnet_synthia_cvpr 781 | elif [ $model = 41 ] && [ -z $ALL_SEGMENTATION_LEGACY ]; then 782 | download_fcn_alexnet_synthia_summer_sd 783 | elif [ $model = 42 ] && [ -z $ALL_SEGMENTATION_LEGACY ]; then 784 | download_fcn_alexnet_synthia_summer_hd 785 | elif [ $model = 43 ]; then 786 | download_image_processing 787 | elif [ $model = 44 ] && [ -z $ALL_IMAGE_PROCESSING ]; then 788 | download_deep_homography_coco 789 | elif [ $model = 45 ] && [ -z $ALL_IMAGE_PROCESSING ]; then 790 | download_super_resolution_bsd500 791 | fi 792 | done 793 | fi 794 | 795 | exit_message 0 796 | else 797 | echo "$LOG Model selection cancelled." 798 | exit_message 0 799 | fi 800 | 801 | exit_message 0 802 | done 803 | 804 | -------------------------------------------------------------------------------- /scripts/test_virtio.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # retrieve path 16 | SCRIPTPATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ) 17 | 18 | # Default path to vAccel installation 19 | VACCEL_PATH=/opt/vaccel 20 | 21 | # Timeout waiting for Firecracker response 22 | SSH_TIMEOUT=300 23 | 24 | # Firecracker IP 25 | FC_IP="172.42.0.2" 26 | 27 | # script name for logging 28 | LOG_NAME="$(basename $0)" 29 | 30 | source $SCRIPTPATH/utils.sh 31 | 32 | print_help() { 33 | echo "" 34 | echo "Usage: ./test-virtio.sh []" 35 | echo "" 36 | echo "Arguments:" 37 | echo " -v|--vaccel Directory of vAccel installation (default: '/opt/vaccel')" 38 | echo " -t|--timeout Timeout in seconds to wait response from Firecracker (default: 300)" 39 | echo " -a|--ip-address Address of Firecracker VM" 40 | echo "" 41 | } 42 | 43 | _run_ssh_test() { 44 | ssh -o StrictHostKeyChecking=no root@$FC_IP $1 45 | } 46 | 47 | test_image_classification() { 48 | in_fc_cmd="LD_LIBRARY_PATH=$VACCEL_PATH/lib" 49 | in_fc_cmd="$in_fc_cmd VACCEL_BACKENDS=$VACCEL_PATH/lib/libvaccel-virtio.so" 50 | in_fc_cmd="$in_fc_cmd VACCEL_DEBUG_LEVEL=4" 51 | in_fc_cmd="$in_fc_cmd $VACCEL_PATH/bin/classify $VACCEL_PATH/share/images/dog_1.jpg 1" 52 | 53 | _run_ssh_test "$in_fc_cmd" 54 | } 55 | 56 | run_tests() { 57 | test_image_classification 58 | } 59 | 60 | main() { 61 | while [ $# -gt 0 ]; do 62 | case "$1" in 63 | -h|--help) { print_help; exit 1; };; 64 | -v|--vaccel) { VACCEL_PATH=$2; shift; };; 65 | -t|--timeout) { SSH_TIMEOUT=$2; shift; };; 66 | -a|--ip-address) { FC_IP=$2; shift; };; 67 | *) 68 | die "Unknown argument: \"$1\". Please use \`$0 --help\`." 69 | ;; 70 | esac 71 | shift 72 | done 73 | 74 | run_tests 75 | } 76 | 77 | main "$@" 78 | -------------------------------------------------------------------------------- /scripts/test_vsock.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | # retrieve path 17 | SCRIPTPATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ) 18 | 19 | # Default path to vAccel installation 20 | VACCEL_PATH=/opt/vaccel 21 | 22 | # Timeout waiting for Firecracker response 23 | SSH_TIMEOUT=300 24 | 25 | # Firecracker IP 26 | FC_IP="172.42.0.2" 27 | 28 | # vsock socket to use inside the VM 29 | VACCEL_VSOCK="vsock://2:2048" 30 | 31 | # unix socket to use on the host 32 | VACCEL_UNIX="unix:///tmp/vaccel.sock_2048" 33 | 34 | # plugin to use for agent 35 | PLUGIN="libvaccel-jetson.so" 36 | 37 | # Agent binary prefix 38 | AGENT_PREFIX="/opt/cargo/bin" 39 | 40 | # Agent PID 41 | AGENT_PID= 42 | 43 | # script name for logging 44 | LOG_NAME="$(basename $0)" 45 | 46 | source $SCRIPTPATH/utils.sh 47 | 48 | print_help() { 49 | echo "" 50 | echo "Usage: ./test-virtio.sh []" 51 | echo "" 52 | echo "Arguments:" 53 | echo " -v|--vaccel Directory of vAccel installation (default: '/opt/vaccel')" 54 | echo " -t|--timeout Timeout in seconds to wait response from Firecracker (default: 300)" 55 | echo " -a|--ip-address Address of Firecracker VM" 56 | echo " -p|--plugin Plugin to use for agent" 57 | echo " --agent-prefix Location of the agent binary" 58 | echo " --vsock Vsock socket to use inside the VM" 59 | echo " --unix Unix socket to use on host" 60 | echo "" 61 | } 62 | 63 | launch_agent() { 64 | info "Running agent with plugin: $PLUGIN" 65 | VACCEL_DEBUG_LEVEL=4 VACCEL_BACKENDS=$PLUGIN $AGENT_PREFIX/vaccelrt-agent -a $VACCEL_UNIX & 66 | AGENT_PID=$! 67 | 68 | # Wait a couple of seconds to let the agent start 69 | sleep 2 70 | } 71 | 72 | kill_agent() { 73 | kill -9 $AGENT_PID 74 | } 75 | 76 | _run_ssh_test() { 77 | ssh -o StrictHostKeyChecking=no root@$FC_IP $1 78 | } 79 | 80 | test_image_classification() { 81 | info "Testing image classification" 82 | in_fc_cmd="LD_LIBRARY_PATH=$VACCEL_PATH/lib" 83 | in_fc_cmd="$in_fc_cmd VACCEL_BACKENDS=$VACCEL_PATH/lib/libvaccel-vsock.so" 84 | in_fc_cmd="$in_fc_cmd VACCEL_VSOCK=$VACCEL_VSOCK" 85 | in_fc_cmd="$in_fc_cmd VACCEL_DEBUG_LEVEL=4" 86 | in_fc_cmd="$in_fc_cmd $VACCEL_PATH/bin/classify $VACCEL_PATH/share/images/dog_1.jpg 1" 87 | 88 | _run_ssh_test "$in_fc_cmd" 89 | } 90 | 91 | test_tf_inference() { 92 | info "Testing TensorFlow inference" 93 | in_fc_cmd="LD_LIBRARY_PATH=$VACCEL_PATH/lib" 94 | in_fc_cmd="$in_fc_cmd VACCEL_BACKENDS=$VACCEL_PATH/lib/libvaccel-vsock.so" 95 | in_fc_cmd="$in_fc_cmd VACCEL_VSOCK=$VACCEL_VSOCK" 96 | in_fc_cmd="$in_fc_cmd VACCEL_DEBUG_LEVEL=4" 97 | in_fc_cmd="$in_fc_cmd $VACCEL_PATH/bin/tf_inference $VACCEL_PATH/share/models/tf/lstm2" 98 | 99 | _run_ssh_test "$in_fc_cmd" 100 | } 101 | 102 | test_tf_saved_model() { 103 | info "Testing TensorFlow SavedModel resource API" 104 | in_fc_cmd="LD_LIBRARY_PATH=$VACCEL_PATH/lib" 105 | in_fc_cmd="$in_fc_cmd VACCEL_BACKENDS=$VACCEL_PATH/lib/libvaccel-vsock.so" 106 | in_fc_cmd="$in_fc_cmd VACCEL_VSOCK=$VACCEL_VSOCK" 107 | in_fc_cmd="$in_fc_cmd VACCEL_DEBUG_LEVEL=4" 108 | in_fc_cmd="$in_fc_cmd $VACCEL_PATH/bin/tf_saved_model $VACCEL_PATH/share/models/tf/lstm2" 109 | 110 | _run_ssh_test "$in_fc_cmd" 111 | } 112 | 113 | run_tests() { 114 | launch_agent 115 | ok_or_die "Could not launch agent" 116 | 117 | test_image_classification 118 | retval=$? 119 | if [[ $retval -ne 0 ]] 120 | then 121 | err "image classification failed: $retval" 122 | kill_agent 123 | exit $retval 124 | fi 125 | 126 | test_tf_inference 127 | retval=$? 128 | if [[ $? -ne 0 ]] 129 | then 130 | err "TensorFlow inference failed: $retval" 131 | kill_agent 132 | exit $retval 133 | fi 134 | 135 | test_tf_saved_model 136 | retval=$? 137 | if [[ $? -ne 0 ]] 138 | then 139 | err "TensorFlow SavedModel resource API failed: $retval" 140 | kill_agent 141 | exit $retval 142 | fi 143 | } 144 | 145 | main() { 146 | while [ $# -gt 0 ]; do 147 | case "$1" in 148 | -h|--help) { print_help; exit 1; };; 149 | -v|--vaccel) { VACCEL_PATH=$2; shift; };; 150 | -t|--timeout) { SSH_TIMEOUT=$2; shift; };; 151 | -a|--ip-address) { FC_IP=$2; shift; };; 152 | -p|--plugin) { PLUGIN=$2; shift; };; 153 | --agent-prefix) { AGENT_PREFIX=$2; shift; };; 154 | --vsock) { VACCEL_VSOCK=$2; shift; };; 155 | --unix) { VACCEL_UNIX=$2; shift; };; 156 | *) 157 | die "Unknown argument: \"$1\". Please use \`$0 --help\`." 158 | ;; 159 | esac 160 | shift 161 | done 162 | 163 | run_tests 164 | } 165 | 166 | main "$@" 167 | -------------------------------------------------------------------------------- /scripts/utils.sh: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | info() { 14 | [ -t 1 ] && [ -n "$TERM" ] \ 15 | && echo "$(tput setaf 2)[$LOG_NAME]$(tput sgr0) $*" \ 16 | || echo "[$LOG_NAME] $*" 17 | } 18 | 19 | err() { 20 | [ -t 2 ] && [ -n "$TERM" ] \ 21 | && echo -e "$(tput setaf 1)[$LOG_NAME]$(tput sgr0) $*" 1>&2 \ 22 | || echo -e "[$LOG_NAME] $*" 1>&2 23 | } 24 | 25 | die() { 26 | err "$@" 27 | exit 1 28 | } 29 | 30 | ok_or_die() { 31 | if [ $? -ne 0 ]; then 32 | die $1 33 | fi 34 | } 35 | --------------------------------------------------------------------------------