【发布时间】:2021-04-07 02:27:15
【问题描述】:
import torch
def forward(x):
return x * w
def loss(x, y):
y_pred = forward(x)
return (y_pred - y) ** 2
x_data = [1.0, 2.0, 3.0]
y_data = [2.0, 4.0, 6.0]
w = torch.Tensor([1.0])
w.requires_grad = True
print("predict (before training)", 4, forward(4).item())
for epoch in range(100):
for x, y in zip(x_data, y_data):
l = loss(x, y)
l.backward()
print('\tgrad:', x, y, w.grad.item())
w.data = w.data - 0.01 * w.grad.data
w.grad.data.zero_()
print("progress:", epoch, l.item())
print("predict (after training)", 4, forward(4).item())
Linux 发行版是 Ubuntu 18.04
GPU:GeForce RTX 2080 SUPER
GPU 驱动程序:NVIDIA UNIX x86_64 内核模块 450.80.02
CUDA:Cuda 编译工具,11.0 版,V11.0.194
cudNN:8.0.3
pytorch:1.7.0,py3.6_cuda11.0.221_cudnn8.0.3_0
蟒蛇:3.6
代码很简单,但运行时会冻结整个计算机
屏幕、键盘、鼠标,完全没有反应
【问题讨论】:
-
我无法复制您遇到的问题,您提供的代码对我有用。
标签: python deep-learning crash pytorch nvidia