第n次安装了,每次都得结合很多篇才能安装成功,这次直接自己写一个。

一、安装anaconda

这个自己搜吧,挺简单的。

二、安装pytorch

进入anaconda prompt

创建一个虚拟环境(就不用再安装python了,创建之后直接就是用的3.8版本的python)

conda create -n env_name python=3.8

进入虚拟环境

conda activate env_name

使用清华镜像源(使用http而不是https,参考这篇博客

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

安装pytorch(官网

  • 不要用pip并去掉-c python的方法(会默认下载cpu),用conda直接复制run this command(其实挺快的);
  • 如果电脑没有gpu那就不要选cuda11.3,选cpu 
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

三、验证

没报错,而且是True(电脑没有gpu的小伙伴就是false啦)

四、镜像源安装其他库

scikit-learn

pip install sklearn -i https://pypi.tuna.tsinghua.edu.cn/simple 

pandas

pip install pandas -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com/pypi/simple

rdkit

conda install -c conda-forge rdkit

有setup.py的安装文件

cd 文件夹_name
python setup.py install
物联沃分享整理
物联沃-IOTWORD物联网 » 记录一次pytorch的安装

发表评论