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.
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.yml
Option 2: Deploy the HAMi
helm repo add hami-charts https://project-hami.github.io/HAMi/
helm install hami hami-charts/hami -n kube-system
- Download the latest release of the fake GPU.
wget https://github.com/chaunceyjiang/fake-gpu/releases/download/v0.3.0/fake-gpu-helm-chart-v0.3.0.tgz
- Deploy the fake GPU to your Kubernetes cluster.
helm install fake-gpu fake-gpu-helm-chart-v0.3.0.tgz
- Configure 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 | 0MiB / 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.yaml
We 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.