美文网首页
2023-01-14 pytorch安装笔记

2023-01-14 pytorch安装笔记

作者: 胜果铺子 | 来源:发表于2023-01-13 13:32 被阅读0次

WSL2 下安装 pytorch

安装 miniconda

参考这篇文章

下载安装脚本并运行。

wget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

退出终端,重新打开。让 .bashrc 里的设置运行生效。

创建虚拟环境

创建新的环境

conda create -n torch1 python=3.10
conda activate torch1

如果创建环境时不加 python 及其版本则接下来会无法运行 pip

安装 pytorch

参考这篇

pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 -i https://pypi.tuna.tsinghua.edu.cn/simple

测试 pytorch 是否能使用 GPU

参考这篇

>>> import torch

>>> torch.cuda.is_available()
True

>>> torch.cuda.device_count()
1

>>> torch.cuda.current_device()
0

>>> torch.cuda.device(0)
<torch.cuda.device at 0x7efce0b03be0>

>>> torch.cuda.get_device_name(0)
'GeForce GTX 950M'

相关文章

网友评论

      本文标题:2023-01-14 pytorch安装笔记

      本文链接:https://www.haomeiwen.com/subject/qhugcdtx.html