According to this link, you need to install the latest CUDA to make the GPU accessible.
So follow the official instruction to install CUDA 12.8, and install pytorch-nightly later:
pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu128
After BIOS update, you might need to disable Secure Boot in BIOS to activate the driver again.
https://askubuntu.com/a/1153093