siyiwei

导航

 

1 创建虚拟环境

  1. 打开命令行界面(例如,Anaconda Prompt或终端)。

  2. 使用命令创建一个新的虚拟环境:

    conda create --name xxx python=3.8
    

    这里xxx是你想要设置的环境名称,python=3.8是指定的Python版本,可以根据需要更改。

  3. 激活新创建的虚拟环境:

    conda activate your_env_name
    
  4. 安装所需的包和库:

    conda install numpy
    

    或者使用pip install命令。

  5. 如果需要,你可以使用以下命令退出虚拟环境:

    conda deactivate
    

2 安装pytorch

  1. 这个例子是安装2.2.1cuda版本的一个例子
pip install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 --index-url https://download.pytorch.org/whl/rocm5.7

3 更换清华源

  1. 对于pip
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
  1. 对于conda
    可以依次使用
conda activate xxx #激活环境
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
posted on 2024-12-25 21:52  huliaohaha  阅读(166)  评论(0)    收藏  举报