安装Pytorch时遇到的问题记录

参考视频
https://www.bilibili.com/video/BV1Lv41177BW/?spm_id_from=333.999.0.0&vd_source=7a297c70b00210465c3ca30254c6ea6c
在这个视频中,先安装TensorFlow,再安装Pytorch,没有更换虚拟环境,可能导致后面安装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。

在这里插入图片描述

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())

在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
根据引用中提供的信息,您使用的是Python3.7、Torch1.12、VsCode和Nvidia 4090。关于PyTorch安装,可以参考引用中提供的命令行安装指令: conda install pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge 这个命令可以在conda环境中安装带有CUDA 11.6编译的PyTorch。请确保您的环境已经安装了相应的CUDA Toolkit版本。如果您遇到安装问题,可以根据引用中提供的安装教程参考,因为每个人的电脑环境和服务器配置不同,可能会出现不同的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ubuntu22.04更换RTX 4090显卡后,安装驱动和pytorch记录](https://blog.csdn.net/u011876981/article/details/127382412)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [从 X 入门Pytorch——环境安装建议,Tensor多种构造方式,Tensor的基本操作](https://blog.csdn.net/qq_44864833/article/details/129581337)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值