Install CUDA in a Laptop with RTX 3050 but version 12.1

Okay I had the a lot of problems installing CUDA cause I did not understand how, here are some suggestions for whoever have the problem:
Windows 11
GPU: RTX 3050 (portable/Laptop)
Python: 3.12.4

  1. Download Visual Stdio Community 2019 (V. 16.11), download ALL then install.

  2. I am using anaconda envs, so these is the command that worked for me:
    conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia

3)From Cuda ToolkitArchive, the version 12.1.0 (February 2023), link here: CUDA Toolkit Archive | NVIDIA Developer

  1. From CUDNN, selected the versio v8.9.7 for CUDA 12.x (december,5th,2023): cuDNN Archive | NVIDIA Developer

5)Replace (overwrite/replace) the docs from ProgramFiles/NVIDIA GPU Computing Toolkit/Cuda/YourVersion (Same as download), replace the different files from the cudnn…download (the ones in the Folders → include, lib, bin to the rogramFiles/NVIDIA GPU Computing Toolkit/Cuda/YourVersion)

  1. In my case the Enviroment Variables were not necesarry change them

  2. Install in yoru CONDA Envioroment with the next command:
    conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia

At the end, using the next lines of code:

import torch

print(torch.version)
print(torch.cuda.is_available()) correctamente
print(torch.cuda.get_device_name(0))

I got the next:
2.3.1
True
NVIDIA GeForce RTX 3050 Laptop GPU

Some of the solutions (as the correct instalation of the binaries where extract from this video: https://www.youtube.com/watch?v=r7Am-ZGMef8 → SL7 Tech / “How to setup NVIDIA GPU for Pytorch on windows 10/11”)