PyTorch 是与TensorFlow 并驾齐驱的深度学习框架,功能各有所长,因此,两个套件通常会一并安装,有关 TensorFlow 安装请参看『Day 01:轻松掌握 Keras』。
PyTorch 安装可透过『PyTorch官网』的选单,产生安装指令,使用 conda 或 pip 均可,例如下图:
conda 产生的安装指令如下:
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
pip 产生的安装指令如下:
pip install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio===0.10.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
以 Python 执行下列程序码验证CUDA安装是否成功:
import torch
tensor = torch.rand(3,4)
print(f"Device tensor is stored on: {tensor.device}")
# Device tensor is stored on: cpu
print(torch.cuda.is_available())
#True
tensor = tensor.to('cuda')
print(f"Device tensor is stored on: {tensor.device}")
# Device tensor is stored on: cuda:0
安装时费了一番手脚,将惨痛的经验分享如下:
<<: Python 演算法 Day 10 - Feature Selection
>>: 移动设备安全政策是防止影子 IT 使用的最佳安全控制
我实在对於密码学非常不熟悉,所以找了一下,目前最适合我使用的范例程序码来自於 … PythonでAE...
盒胡图 可用来观察资料的分布情形 最大值、最小值、中位数、四分位数 一样使用Titanic资料集做示...
Array 是一个有序的集合,可以存储相同类型的元素。 初始化: // 1. init时就有值 NS...
我主要身分是软件工程师,参赛ARM主题纯粹是兴趣,毕竟隔行如隔山,软件、韧体、硬体差异太大。希望在这...
作者:徐育伟 现为零一零科技工程师 台湾科技大学 工业管理系 一切都要从大四开始说起... 那年选修...