nerc-project / operations

Issues related to the operation of the NERC OpenShift environment
2 stars 0 forks source link

OpenShift Virtualization testing—VMs with GPUs #725

Open computate opened 1 month ago

computate commented 1 month ago

Edit by naved001: Blocked as of 10/22/2024 on getting access to a GPU.

naved001 commented 1 month ago

I imagine we would want to test passing a single GPU and multiple GPUs

jtriley commented 1 month ago

Some docs to read up on:

https://docs.openshift.com/container-platform/4.14/virt/virtual_machines/advanced_vm_management/virt-configuring-virtual-gpus.html

We should be able to test this soon given that we now have a V100 host in the ocp-test cluster.

jtriley commented 1 month ago

Looks like there's device mediation (ie vGPUs) and PCI-passthrough support depending on what cards are supported. For mediation there are two approaches - one that uses the NVIDIA GPU operator to do the mediation and one that relies on RH OpenShift Virtualization operator to do the setup. Need to read up on that and PCI passthrough:

computate commented 1 month ago

Note from the NERC: HU/BU Weekly Team Meeting that Dan McPherson would like to test GPUs on OpenShift Virtualization.

naved001 commented 1 month ago

@jtriley Is there a reason why the only GPU node in the test cluster has scheduling disabled?

➜  ~    oc get nodes -l 'nvidia.com/gpu.product=Tesla-V100-PCIE-32GB'
NAME    STATUS                     ROLES    AGE   VERSION
wrk-3   Ready,SchedulingDisabled   worker   22d   v1.28.12+396c881

I want to start testing PCI pass-through for GPUs.

jtriley commented 1 month ago

@jtriley Is there a reason why the only GPU node in the test cluster has scheduling disabled?

Not that I'm aware of - maybe @dystewart has it temporarily disabled? I think he's working on the GPU-scheduling (https://github.com/nerc-project/operations/issues/495) on that cluster IIRC.

naved001 commented 1 month ago

@dystewart let me know once you are done with your testing and I can then proceed with this issue once the GPU is available.

naved001 commented 1 month ago

For mediation there are two approaches - one that uses the NVIDIA GPU operator to do the mediation and one that relies on RH OpenShift Virtualization operator to do the setup.

Apparently both of those method require the nvidia vGPU Software which requires a license to get. Do we have such a license for these GPUs?

computate commented 1 month ago

@hpdempsey are we able to get an NVIDIA vGPU Software license to test VMs with GPUs? See above ^.

naved001 commented 1 month ago

@computate just to be clear, that software is required if we want to test VMs with vGPUs which are partitioned nvidia GPUs. For PCI passthrough of a whole GPU we do not need that license (I plan to do that once the GPU becomes available).

dystewart commented 1 month ago

@naved001 yeah sorry, I'm still playing around with a couple things on the gpu so have it cordoned rn, very close to finished up though!

naved001 commented 1 month ago

@dystewart no rush, thank you for the heads up!

okrieg commented 1 month ago

This is all about functionality, but one of the things we will need to do is evaluate the performance when you use GPUs virtualized versus physical; Apoorve is working on this at IBM

joachimweyl commented 2 weeks ago

@naved001 please provide an update on how things are going and the next steps.

naved001 commented 2 weeks ago

@joachimweyl I am blocked on getting access to a GPU to test this. I have a draft PR which will enable GPU pass-through for V100.

joachimweyl commented 3 days ago

@naved001 are you still blocked on this or did the Nvidia fix and access to the V100 resolve this blockage?

naved001 commented 2 days ago

I merged the PR that should enable testing this but it appears that the machineconfig update hasn't rolled out and is stuck in updating state, so need to take a look at that.

naved001 commented 2 days ago

@computate The machineconfig didn't apply because the nodes can't be drained. I see this in the logs

[machine-config-controller-6c9484cd9-bgcmb machine-config-controller] I1106 19:40:05.732003       1 drain_controller.go:152] evicting pod knative-serving/activator-7cbf6b7785-sb4zv
[machine-config-controller-6c9484cd9-bgcmb machine-config-controller] E1106 19:40:05.751303       1 drain_controller.go:152] error when evicting pods/"activator-7cbf6b7785-sb4zv" -n "knative-serving" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
[machine-config-controller-6c9484cd9-bgcmb machine-config-controller] I1106 19:40:05.762227       1 drain_controller.go:152] evicting pod knative-serving/webhook-6cd8bdbdc7-n5g8w
[machine-config-controller-6c9484cd9-bgcmb machine-config-controller] E1106 19:40:05.779561       1 drain_controller.go:152] error when evicting pods/"webhook-6cd8bdbdc7-n5g8w" -n "knative-serving" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.

Do you know where those pods in knative-serving namespace come from and if we can do something about those?

computate commented 2 days ago

@naved001 I wouldn't worry about evicting knative-serving pods in the prod cluster. They just come with the operator. You can delete them if you want.

naved001 commented 1 day ago

After the machineconfig changes were applied. I can see that the GPU device is bound to the vfio driver

[core@wrk-3 ~]$ lspci -nnk -d 10de:
3b:00.0 3D controller [0302]: NVIDIA Corporation GV100GL [Tesla V100 PCIe 32GB] [10de:1db6] (rev a1)
    Subsystem: NVIDIA Corporation Device [10de:124a]
    Kernel driver in use: vfio-pci
    Kernel modules: nouveau

And if we describe the node wrk-3 we can see that the 1 GPU device shows up as allocatable.

nvidia.com/GV100GL_Tesla_V100:  1

I will now test passing it to a VM.

naved001 commented 1 day ago

I can confirm that I can launch a VM with 1 GPU on wrk-3 (only it has 1 GPU).

You can SSH to the VM with virtctl -n virt-test ssh centos@naved-test-gpu

I launched my VM from a centos9 template so I edited it to have access to the GPU.

➜  ~ oc get vm -n virt-test naved-test-gpu -o yaml | yq .spec.template.spec.domain.devices.hostDevices
[
  {
    "deviceName": "nvidia.com/GV100GL_Tesla_V100",
    "name": "hostdevices1"
  }
]

Once the VM launched I could see the GPU device in lspci. After that I installed the nvidia drivers and I could run nvidia-smi.

[centos@naved-test-gpu ~]$ lspci |grep -i nvidia
09:00.0 3D controller: NVIDIA Corporation GV100GL [Tesla V100 PCIe 32GB] (rev a1)
[centos@naved-test-gpu ~]$ nvidia-smi
Thu Nov  7 14:41:31 2024
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 565.57.01              Driver Version: 565.57.01      CUDA Version: 12.7     |
|-----------------------------------------+------------------------+----------------------+
| 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. |
|=========================================+========================+======================|
|   0  Tesla V100-PCIE-32GB           Off |   00000000:09:00.0 Off |                    0 |
| N/A   35C    P0             25W /  250W |       1MiB /  32768MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

@jtriley @computate what other tests do we want to perform for this issue? I am thinking of maybe testing the A100 machine since it has multiple GPUs. In that case I'll reset this machine so that @dystewart could use this.

computate commented 6 hours ago

@naved001 you could try a simple Tensorflow test.

# Test Python Tensorflow with GPU: 

pip install tensorflow numpy matplotlib torch --upgrade
python3 -m pip install tensorflow[and-cuda] --upgrade

# Make sure this command returns a tensor in the array: 
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
computate commented 6 hours ago

@naved001 or you could try running InstructLab. Something like this:

git clone https://github.com/instructlab/instructlab.git
cd instructlab/
sudo dnf install python3.11 python3.11-devel
python3.11 -m venv venv
python3 -m venv --upgrade-deps venv
source venv/bin/activate
pip install packaging wheel torch
pip install 'instructlab[cuda]' \
   -C cmake.args="-DLLAMA_CUDA=on" \
   -C cmake.args="-DLLAMA_NATIVE=off"

CUDACXX=/usr/local/cuda-12/bin/nvcc CMAKE_ARGS="-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=native" FORCE_CMAKE=1 CUDAHOSTCXX=$(which clang++-17) pip install --force-reinstall --no-deps llama_cpp_python==0.2.79 -C cmake.args="-DLLAMA_CUDA=on"

ilab data generate --pipeline=full --num-cpus 8 --gpus 1 --taxonomy-base=empty
ilab chat

sudo dnf install pciutils
lspci -n -n -k | grep -A 2 -e VGA -e 3D

ilab init
ilab download
ilab model serve
ilab data generate --pipeline=full --num-cpus 8 --gpus 1 --taxonomy-base=empty
ilab data generate --taxonomy-base=origin/cmb-run-2024-08-26
computate commented 6 hours ago

@Milstein has an awesome model training Jupyter notebook with examples as well!

naved001 commented 3 hours ago

@computate I did the simple test and can confirm that the GPU device is usable in tensorflow.

>>> gpus = tensorflow.config.list_physical_devices('GPU')
>>> gpus
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
>>> print(tensorflow.config.experimental.get_device_details(gpus[0]))
{'compute_capability': (7, 0), 'device_name': 'Tesla V100-PCIE-32GB'}