安装Pytorch时遇到的问题记录

参考视频
https://www.bilibili.com/video/BV1Lv41177BW/?spm_id_from=333.999.0.0&vd_source=7a297c70b00210465c3ca30254c6ea6c
在这个视频中,先安装TensorFlow,再安装Pytorch,没有更换虚拟环境,可能导致后面安装Pytorch时版本不兼容问题非常麻烦,所以最好另外新建一个虚拟环境。下面是步骤:
【1】问题界面
安装Pytorch时遇到的问题记录_第1张图片
If python is on the left-most side of the chain, that’s the version you’ve asked for.When python appears to the right, that indicates that the thing on the left is somehow not available for the python version you are constrained to. Note that conda will not change your python version to a different minor version unless you explicitly specify that.
【2】打开 Anaconda Prompt 或终端,新建一个虚拟环境:

conda create -n pytorch python=3.8.5

【3】根据CUDA版本,选择pytorch。

安装Pytorch时遇到的问题记录_第2张图片

conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.1 -c pytorch

【4】结果

def func2():
    print("Python版本:", sys.version)
    print("PyTorch 版本:", torch.__version__)
    print("CUDA 可用性:", torch.cuda.is_available())
    print("CUDA 版本:", torch.version.cuda)
    print("cuDNN 版本:", torch.backends.cudnn.version())
    print("设备数量:", torch.cuda.device_count())
    print("当前设备索引:", torch.cuda.current_device())
    print("当前设备名称:", torch.cuda.get_device_name())

安装Pytorch时遇到的问题记录_第3张图片

你可能感兴趣的:(pytorch,python,人工智能)