The fake-gpu project is designed to simulate GPU information, making it easier to test scenarios where a GPU is not available. This can be particularly useful for development and testing purposes in environments that lack physical GPU hardware.
- Simulate GPU information through configuration files
- Unable to Perform Genuine CUDA Computation
- Test GPU-related functions without GPU hardware
- Non-intrusive, no need to modify application code
- Supports CUDA Driver, CUDA Runtime, NVML API
- Supports nvidia-smi
- Supports DCGM-Exporter
- containerd >= 1.7.0
To use the fake GPU, follow these steps:
You should have a Kubernetes cluster running with containerd as the container runtime. You should have already deployed nvidia-device-plugin or HAMi.
- Download the latest release of the fake GPU.
helm repo add fake-gpu-charts https://chaunceyjiang.github.io/fake-gpu
helm repo update- Deploy the fake GPU to your Kubernetes cluster.
helm install fake-gpu fake-gpu-charts/fake-gpu -n kube-system
You need to deploy a device plugin to advertise the fake GPU resource to the Kubernetes cluster. You can use either the NVIDIA device plugin or HAMi.
Nvidia Device Plugin or HAMi only chooses one of them. recommends using HAMi.
Option 2: Deploy the HAMi (Recommended)
helm repo add hami-charts https://project-hami.github.io/HAMi/
helm install hami hami-charts/hami -n kube-system
Option 1: Deploy the nvidia-device-plugin
kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v0.17.0/deployments/static/nvidia-device-plugin.ymlConfigure your application to use the GPU.
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: fake-gpu
spec:
containers:
- name: fake-gpu
image: nginx
resources:
limits:
nvidia.com/gpu: 1
EOF- Run your application as you would with a real GPU.
kubectl exec -it fake-gpu -- nvidia-smi
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 470.129.06 Driver Version: 440.33.01 CUDA Version: 12.2 |
+-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
+-----------------------------------------+----------------------+----------------------+
| 1 NVIDIA Tesla P4 Off | Off | Off |
| N/A 33C P8 11W / 70W | 3200MiB / 15411MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
+---------------------------------------------------------------------------------------+
| 1 N/A N/A 19 G /usr/local/nginx 3200MiB |
+---------------------------------------------------------------------------------------+To compile the project, follow these steps:
make docker-build IMAGE_VERSION=v0.2.0
helm template charts/fake-gpu --set imag.repository=chaunceyjiang/fake-gpu --set image.tag=v0.2.0 --set nri.runtime.patchConfig=false > install.yaml
kubectl apply -f install.yamlWe welcome contributions to the fake-gpu project. To contribute, follow these guidelines:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Make your changes and commit them with descriptive commit messages.
- Push your changes to your forked repository.
- Create a pull request to the main repository.
Please ensure your code follows the project's coding standards and includes appropriate tests.