参考博客:
1\][虚拟环境conda安装cuda11.7和cudnn和pytorch](https://blog.csdn.net/weixin_44589524/article/details/131663046) \[2\][conda环境下安装nvcc -V](https://blog.csdn.net/Aorg1/article/details/134800426) \[3\][解决 nvcc -V 显示的cuda版本不正确](https://www.cnblogs.com/hf19950918/p/14707662.html) #查看当前cuda情况 ```bash nvcc -V ``` #查看cudatoolkit的可安装版本 ```bash conda search cudatoolkit --info ``` #安装cudatoolkit ```bash conda install cudatoolkit ``` #安装cuda11.7和对应的pytorch等环境 ```bash conda install pytorch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 pytorch-cuda=11.7 -c pytorch -c nvidia ``` #查看包里面是否包含cuda 11.7 ```bash conda list ``` #需要在cudatoolkit安装之后!!! ```bash conda install cudnn ``` #在python中查看cuda版本是否正确 ```bash python >>>import torch >>>print(torch.version.cuda) #11.7 >>>print(torch.backends.cudnn.version()) #8500 ``` #运行时发现nvcc -V版本还是不合适(尝试在conda下安装nvcc) #查找对应版本nvcc ```bash conda search -c nvidia cuda-nvcc ``` #安装nvcc ```bash conda install -c nvidia cuda-nvcc==12.2.140 #或者是11.7.99 ```