pytorch错误非法指令(核心已转储)

时间:2018-11-18 08:22:00

标签: python neural-network pytorch

我已经安装了pytorch版本0.4.1

我直接使用pip而不是conda来安装它,我还注意到问题出在二进制文件上,以及我对C gcc版本与处理器不兼容的研究。 我的gcc版本是7.3.0

我的处理器类型为AMD A8-7410 APU with AMD Radeon R5 Graphics

gcc位置。

(data-science) sam@sam-Lenovo-G51-35:~/code/data science projects/pytorch$ which gcc
/usr/bin/gcc

这就是我得到错误的方式。

下面的代码运行...

from torchvision import datasets, transforms
from torch import nn
import torch
import torch.nn.functional as F

# Define a transform to normalize the data
transform = transforms.Compose([transforms.ToTensor(),
                              transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),
                              ])

# Download and load the training data
trainset = datasets.MNIST('MNIST_data/', download=True, train=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=64, shuffle=True)

dataiter = iter(trainloader)
images, labels = dataiter.next()

class Network(nn.Module):
    def __init__(self):
        super(Network, self).__init__()
        # Defining the layers, 128, 64, 10 units each
        self.fc1 = nn.Linear(784, 128)
        self.fc2 = nn.Linear(128, 64)
        # Output layer, 10 units - one for each digit
        self.fc3 = nn.Linear(64, 10)

    def forward(self, x):
        ''' Forward pass through the network, returns the output logits '''

        x = self.fc1(x)
        x = F.relu(x)
        x = self.fc2(x)
        x = F.relu(x)
        x = self.fc3(x)
        x = F.softmax(x, dim=1)

        return x

# Create the network and look at it's text representation
model = Network()

# print(model.fc1.weight)
# print(model.fc1.bias)

# Set biases to all zeros
model.fc1.bias.data.fill_(0)

# sample from random normal with standard dev = 0.01
model.fc1.weight.data.normal_(std=0.01)

# Grab some data 
dataiter = iter(trainloader)
images, labels = dataiter.next()

# Resize images into a 1D vector, new shape is (batch size, color channels, image pixels) 
images.resize_(64, 1, 784)
# or images.resize_(images.shape[0], 1, 784) to automatically get batch size

所有这些都成功

但是当我运行另一行

# Forward pass through the network
img_idx = 0
ps = model.forward(images[img_idx,:])

我收到此错误

Illegal instruction (core dumped)

0 个答案:

没有答案