Configure CUDA in PyTorch (VS Code)

I am currently trying to use CUDA in my PyTorch model training within VS Code on the RTX 4050. It is able to detect that there is a GPU and CUDA is available, however, when model training is executed, the GPU is not utilized according to nvidia-smi, Task Manager, and NVIDIA App. At first, I installed CUDA Driver 12.9 and then uninstalled it to install 12.1, but doing nvidia-smi in Bash still prompts the driver as 12.9 despite nvcc --version returning 12.1. I’ve also ensured that I installed the PyTorch version for CUDA 12.1. Is there anything I’m missing or configured incorrectly when setting up CUDA for PyTorch model training?