Set up a heterogeneous confidential computing environment on a gn8v-tee instance and verify GPU confidential computing with sample code.
Background
Alibaba Cloud heterogeneous confidential computing instances (gn8v-tee) extend CPU TDX confidential computing instances by incorporating a GPU into the Trusted Execution Environment (TEE). This protects CPU-GPU data transfers and GPU data computation. To build a CPU TDX confidential computing environment and verify remote attestation, see Build a TDX confidential computing environment. To deploy LLM inference on a heterogeneous confidential computing instance, see Build a measured LLM inference environment on a heterogeneous confidential instance.
The GPU on a heterogeneous confidential computing instance starts in confidential computing mode. The following mechanisms ensure confidentiality:
TDX prevents the Hypervisor/Host OS from accessing the instance's sensitive registers or memory data.
A PCIe firewall prevents the CPU from accessing the GPU's critical registers and protected video memory. The Hypervisor/Host OS can only perform limited operations such as resetting the GPU, but cannot access sensitive data.
The GPU's NVLink Firewall blocks other GPUs from directly accessing its video memory.
During initialization, the GPU driver and library functions within the CPU TEE establish an encrypted channel with the GPU via the SPDM protocol. After key negotiation, only ciphertext is transmitted over PCIe between the CPU and GPU.
The GPU's remote attestation capability confirms that the GPU is in a secure state.
Applications in a confidential computing instance can use the Attestation SDK to call the GPU driver and obtain a cryptographic report of the GPU's security status. This report contains cryptographically signed information about the GPU hardware, VBIOS, and hardware status measurements. A relying party can compare these measurements with reference measurements from the GPU vendor to verify the GPU is in a secure confidential computing state.
Usage notes
Heterogeneous confidential computing requires Alibaba Cloud Linux 3 images. If you use a custom image based on Alibaba Cloud Linux 3, ensure the kernel version is 5.10.134-18 or later.
Create a heterogeneous confidential computing instance (gn8v-tee)
Console
Creating a heterogeneous confidential computing instance is similar to creating a standard instance but requires specific configurations. For general configurations, see Create an instance using the wizard.
Go to ECS console - Instances.
In the upper-left corner of the page, select a region and resource group.
Click Create Instance and configure the instance with the following settings.
Configuration Item
Description
Region and Zone
China (Beijing) Zone L
Instance Type
ecs.gn8v-tee.4xlarge or higher.
Image
Select the Alibaba Cloud Linux 3.2104 LTS 64-bit image.
Public IP Address
Assign Public IPv4 Address. Required to download the NVIDIA driver later.
ImportantWhen creating or restarting a confidential instance with 8 GPUs, do not attach additional secondary ENIs or data disks. This can cause a startup failure.
Complete the instance creation by following the on-screen instructions.
API/CLI
Call the RunInstances operation or use the Alibaba Cloud CLI to create a TDX-enabled ECS instance. Key parameters:
Parameter | Description | Example |
RegionId | China (Beijing) | cn-beijing |
ZoneId | Zone L | cn-beijing-l |
InstanceType | ecs.gn8v-tee.4xlarge or higher. | ecs.gn8v-tee.4xlarge |
ImageId | ID of an image that supports confidential computing. Only 64-bit Alibaba Cloud Linux 3.2104 LTS images with kernel version 5.10.134-18.al8.x86_64 or later. | aliyun_3_x64_20G_alibase_20250117.vhd |
CLI example:
<SECURITY_GROUP_ID>: security group ID.<VSWITCH_ID>: vSwitch ID.<KEY_PAIR_NAME>: SSH key pair name.
aliyun ecs RunInstances \
--RegionId cn-beijing \
--ZoneId cn-beijing-l \
--SystemDisk.Category cloud_essd \
--ImageId 'aliyun_3_x64_20G_alibase_20250117.vhd' \
--InstanceType 'ecs.gn8v-tee.4xlarge' \
--SecurityGroupId '<SECURITY_GROUP_ID>' \
--VSwitchId '<VSWITCH_ID>' \
--KeyPairName <KEY_PAIR_NAME>Build the heterogeneous confidential computing environment
Step 1: Install the NVIDIA driver and CUDA Toolkit
Heterogeneous confidential computing instances take a long time to initialize. Wait until the instance status is Running and the operating system has fully started.
Installation steps vary by instance type:
Single-GPU confidential instances: ecs.gn8v-tee.4xlarge and ecs.gn8v-tee.6xlarge
8-GPU confidential instances: ecs.gn8v-tee-8x.16xlarge and ecs.gn8v-tee-8x.48xlarge
Single-GPU confidential instances
Connect to the confidential computing instance. See Log on to a Linux instance using Workbench.
Set the SWIOTLB buffer to 8 GB.
sudo grubby --update-kernel=ALL --args="swiotlb=4194304,any"Restart the instance. See Restart an instance.
Download the NVIDIA driver and CUDA Toolkit.
Single-GPU confidential instances require driver version
550.144.03or later. This example uses550.144.03.wget --referer=https://www.nvidia.cn/ https://cn.download.nvidia.cn/tesla/550.144.03/NVIDIA-Linux-x86_64-550.144.03.run wget https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda_12.4.1_550.54.15_linux.runInstall dependencies and disable the CloudMonitor service.
sudo yum install -y openssl3 sudo systemctl disable cloudmonitor sudo systemctl stop cloudmonitorCreate and configure
nvidia-persistenced.service.cat > nvidia-persistenced.service << EOF [Unit] Description=NVIDIA Persistence Daemon Wants=syslog.target Before=cloudmonitor.service [Service] Type=forking ExecStart=/usr/bin/nvidia-persistenced --user root ExecStartPost=/usr/bin/nvidia-smi conf-compute -srs 1 ExecStopPost=/bin/rm -rf /var/run/nvidia-persistenced [Install] WantedBy=multi-user.target EOF sudo cp nvidia-persistenced.service /usr/lib/systemd/system/nvidia-persistenced.serviceInstall the NVIDIA driver and CUDA Toolkit.
sudo bash NVIDIA-Linux-x86_64-550.144.03.run --ui=none --no-questions --accept-license --disable-nouveau --no-cc-version-check --install-libglvnd --kernel-module-build-directory=kernel-open --rebuild-initramfs sudo bash cuda_12.4.1_550.54.15_linux.run --silent --toolkitStart the nvidia-persistenced and CloudMonitor services.
sudo systemctl start nvidia-persistenced.service sudo systemctl enable nvidia-persistenced.service sudo systemctl start cloudmonitor sudo systemctl enable cloudmonitor
8-GPU confidential instances
Connect to the confidential computing instance. See Log on to a Linux instance using Workbench.
ImportantConfidential computing instances initialize slowly. Wait for the process to complete before proceeding.
Set the SWIOTLB buffer to 8 GB.
sudo grubby --update-kernel=ALL --args="swiotlb=4194304,any"Configure NVIDIA driver loading behavior and regenerate the initramfs.
sudo bash -c 'cat > /etc/modprobe.d/nvidia-lkca.conf << EOF install nvidia /sbin/modprobe ecdsa_generic; /sbin/modprobe ecdh; /sbin/modprobe --ignore-install nvidia options nvidia NVreg_RegistryDwords="RmEnableProtectedPcie=0x1" EOF' sudo dracut --regenerate-all -fRestart the instance. See Restart an instance.
Download the NVIDIA driver and CUDA Toolkit.
8-GPU confidential computing instances require driver version
570.148.08or later and the correspondingFabric Manager. This example uses570.148.08.wget --referer=https://www.nvidia.cn/ https://cn.download.nvidia.cn/tesla/570.148.08/NVIDIA-Linux-x86_64-570.148.08.run wget https://developer.download.nvidia.com/compute/cuda/12.8.1/local_installers/cuda_12.8.1_570.124.06_linux.run wget https://developer.download.nvidia.cn/compute/cuda/repos/rhel8/x86_64/nvidia-fabric-manager-570.148.08-1.x86_64.rpmInstall dependencies and disable the CloudMonitor service.
sudo yum install -y openssl3 sudo systemctl disable cloudmonitor sudo systemctl stop cloudmonitorCreate and configure
nvidia-persistenced.service.cat > nvidia-persistenced.service << EOF [Unit] Description=NVIDIA Persistence Daemon Wants=syslog.target Before=cloudmonitor.service After=nvidia-fabricmanager.service [Service] Type=forking ExecStart=/usr/bin/nvidia-persistenced --user root --uvm-persistence-mode --verbose ExecStartPost=/usr/bin/nvidia-smi conf-compute -srs 1 ExecStopPost=/bin/rm -rf /var/run/nvidia-persistenced TimeoutStartSec=900 TimeoutStopSec=60 [Install] WantedBy=multi-user.target EOF sudo cp nvidia-persistenced.service /usr/lib/systemd/system/nvidia-persistenced.serviceInstall Fabric Manager, the NVIDIA driver, and the CUDA Toolkit.
sudo rpm -ivh nvidia-fabric-manager-570.148.08-1.x86_64.rpm sudo bash NVIDIA-Linux-x86_64-570.148.08.run --ui=none --no-questions --accept-license --disable-nouveau --no-cc-version-check --install-libglvnd --kernel-module-build-directory=kernel-open --rebuild-initramfs sudo bash cuda_12.8.1_570.124.06_linux.run --silent --toolkitStart and enable the nvidia-fabricmanager, nvidia-persistenced, and cloudmonitor services.
sudo systemctl start nvidia-fabricmanager.service sudo systemctl enable nvidia-fabricmanager.service sudo systemctl start nvidia-persistenced.service sudo systemctl enable nvidia-persistenced.service sudo systemctl start cloudmonitor sudo systemctl enable cloudmonitor
Step 2: Check the TDX status
This feature relies on TDX. Check the TDX status to verify that the instance is protected.
-
Check if TDX is enabled.
lscpu |grep -i tdx_guestIf the output contains
tdx_guest, TDX is enabled.[root@iZwzxxxxxxxx:~]# lscpu |grep -i tdx_guest Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc bts rep_good nopl xtopology tsc_known_freq pni pclmulqdq dtes64 ds_cpl ssse3 sdbg fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single sbd ibrs ibpb stibp ibrs_enhanced tdx_guest fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap avx512ifma clflushopts clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx_vnni avx512_bf16 wbnoinvd avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid bus_lock_detect cldemote movdiri movdir64b _vp2intersect md_clear serialize tsxldtrk amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities Check TDX-related driver installation.
ls -l /dev/tdx_guestThe following output indicates TDX-related drivers are installed.
[ ~@iz2ze ~]# ls -l /dev/tdx_guest crw------- 1 root root 10, 125 Jan 30 16:51 /dev/tdx_guest
Step 3: Check the GPU confidential computing feature status
Single-GPU confidential instances
Check the confidential computing status.
nvidia-smi conf-compute -fCC status: ON indicates confidential computing is enabled. CC status: OFF indicates the feature is disabled due to an instance error. If this occurs, submit a ticket.
8-GPU confidential instances
Check the confidential computing status.
nvidia-smi conf-compute -mgmMulti-GPU Mode: Protected PCIe indicates multi-GPU confidential computing is enabled. Multi-GPU Mode: None indicates the feature is disabled due to an instance error. If this occurs, submit a ticket.
For 8-GPU confidential instances, nvidia-smi conf-compute -f normally returns CC status: OFF.
Step 4: Verify GPU and NVSwitch trust by using local attestation
Single-GPU confidential instances
Install GPU trust dependencies.
sudo yum install -y python3.11 python3.11-devel python3.11-pip sudo alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 60 sudo alternatives --set python3 /usr/bin/python3.11 sudo python3 -m ensurepip --upgrade sudo python3 -m pip install --upgrade pip sudo python3 -m pip install nv_attestation_sdk==2.5.0.post6914366 nv_local_gpu_verifier==2.5.0.post6914366 nv_ppcie_verifier==1.5.0.post6914366 -f https://attest-public-cn-beijing.oss-cn-beijing.aliyuncs.com/repo/pip/attest.htmlVerify the GPU trust status.
python3 -m verifier.cc_admin --user_modeThe output indicates the GPU is in confidential computing mode and measurements such as the driver and VBIOS match expected values:
8-GPU confidential instances
Install GPU trust dependencies.
sudo yum install -y python3.11 python3.11-devel python3.11-pip sudo alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 60 sudo alternatives --set python3 /usr/bin/python3.11 sudo python3 -m ensurepip --upgrade sudo python3 -m pip install --upgrade pip sudo python3 -m pip install nv_attestation_sdk==2.5.0.post6914366 nv_local_gpu_verifier==2.5.0.post6914366 nv_ppcie_verifier==1.5.0.post6914366 -f https://attest-public-cn-beijing.oss-cn-beijing.aliyuncs.com/repo/pip/attest.htmlInstall NVSwitch dependencies.
wget https://developer.download.nvidia.cn/compute/cuda/repos/rhel8/x86_64/libnvidia-nscq-570-570.148.08-1.x86_64.rpm sudo rpm -ivh libnvidia-nscq-570-570.148.08-1.x86_64.rpmVerify the GPU/NVSwitch trust status.
python3 -m ppcie.verifier.verification --gpu-attestation-mode=LOCAL --switch-attestation-mode=LOCALThe sample code verifies eight GPUs and four NVSwitches.
SUCCESSindicates verification passed:All nvSwitches Attested Successfully **************************************************** * PPCIE: Switch attestation result is True * **************************************************** **************************************************** * PPCIE: Switch Attestation Completed * **************************************************** **************************************************** * PPCIE: GPU state is READY * **************************************************** +-------------------------+----------+ | STAGE | STATUS | +-------------------------+----------+ | GPU Pre-checks | SUCCESS | | Switch Pre-checks | SUCCESS | | GPU Attestation | SUCCESS | | Switch Attestation | SUCCESS | | Topology checks | SUCCESS | +-------------------------+----------+ **************************************************** * PPCIE: End of PPCIE Verification Tool * ****************************************************
Limitations
This feature inherits the limitations of TDX instances.
With GPU confidential computing enabled, CPU-GPU data transfers require encryption and decryption, resulting in lower GPU task performance compared to non-confidential heterogeneous instances.
Usage notes
Single-GPU instances use CUDA 12.4. The NVIDIA cuBLAS library has a known issue that may cause errors when running CUDA or LLM tasks. Install a specific cuBLAS version to resolve this.
pip3 install nvidia-cublas-cu12==12.4.5.8With GPU confidential computing enabled, initialization is slow, especially for 8-GPU instances. After the guest OS starts, verify that
nvidia-persistencedhas finished starting before using the GPU withnvidia-smior other commands. Check thenvidia-persistencedservice status:systemctl status nvidia-persistenced | grep "Active: "activating (start)— the service is starting.Active: activating (start) since Wed 2025-02-19 10:07:54 CST; 2min 20s agoactive (running) — the service is running.
Active: active (running) since Wed 2025-02-19 10:10:28 CST; 22s ago
GPU-dependent auto-start services, such as
cloudmonitor.service,nvidia-cdi-refresh.service(from nvidia-container-toolkit-base), orollama.service, must start afternvidia-persistenced.service.Example configuration for
/usr/lib/systemd/system/nvidia-persistenced.service:[Unit] Description=NVIDIA Persistence Daemon Wants=syslog.target Before=cloudmonitor.service nvidia-cdi-refresh.service ollama.service After=nvidia-fabricmanager.service [Service] Type=forking ExecStart=/usr/bin/nvidia-persistenced --user root --uvm-persistence-mode --verbose ExecStartPost=/usr/bin/nvidia-smi conf-compute -srs 1 ExecStopPost=/bin/rm -rf /var/run/nvidia-persistenced TimeoutStartSec=900 TimeoutStopSec=60 [Install] WantedBy=multi-user.target