【深度学习】pytorch深度学习框架的环境配置

发布于:2025-08-19 ⋅ 阅读:(17) ⋅ 点赞:(0)

1. 配置cuda环境

  • 在命令行输入以下命令可以查看当前显卡驱动版本和最高支持的cuda版本
nvidia-smi

在这里插入图片描述

2. 配置conda环境

  • 去官网下载anaconda
    下载链接:https://repo.anaconda.com/archive
  • conda换源
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
    conda config --set show_channel_urls yes
    
  • pip换源
    pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
    
  • 安装uv
    pip install uv
    
  • 安装conda环境(python维护周期查询
    conda create -n [环境名] python=3.x -y
    

3. 配置pytorch gpu环境

  • 先去官网查询安装torch等库的命令
    官网链接:https://pytorch.org/get-started/previous-versions/
  • 使用在命令前加上uv再执行命令提高下载速度,比如
    uv pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu128
    
  • 安装后,运行python,执行以下代码验证是否配置成功
    import torch
    torch.cuda.is_available()
    torch.cuda.get_device_name(0)
    

网站公告

今日签到

点亮在社区的每一天
去签到