Torch.empty(5,3) => " no attribute named 'empty' "

[ Looking for ideas about what I need to read / learn about in order to figure this out. ]

I’m working through the PyTorch tutorial because (1) I’m new to PyTorch, and (2) it’s a way to compare that I’ve got my new home machine (Lambda Labs Quad) set up correctly. I have a different machine at work and the tutorial works fine there.

https://pytorch.org/tutorials/beginner/blitz/tensor_tutorial.html#sphx-glr-beginner-blitz-tensor-tutorial-py

I’m doing this from the >>> prompt with the default user, but separately created a different admin account and, logged in from that account, installed conda and then setup conda environments for TF-GPU and PyTorch. I get the same behavior in a Jupyter notebook.

The behavior

ubuntu@lambda-quad:~/installs$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

from future import print_function
import torch
x = torch.empty(5,3)
Traceback (most recent call last):
File “”, line 1, in
AttributeError: module ‘torch’ has no attribute ‘empty’
exit()

I get this same result with python and python3.

Here’s what is installed (pip list; also apt list --installed | grep ^python)

ubuntu@lambda-quad:~/installs$ pip list
absl-py (0.1.11)
adium-theme-ubuntu (0.3.4)
backports.weakref (1.0.post1)
bleach (1.5.0)
enum34 (1.1.6)
funcsigs (1.0.2)
futures (3.2.0)
h5py (2.7.1)
html5lib (0.9999999)
Keras (2.1.5)
Markdown (2.6.11)
mock (2.0.0)
numpy (1.14.2)
pandas (0.22.0)
pbr (3.1.1)
Pillow (5.0.0)
pip (9.0.1)
protobuf (3.5.2)
psutil (5.4.3)
Pyste (0.9.10)
python-apt (1.1.0b1+ubuntu0.16.4.1)
python-dateutil (2.7.0)
pytz (2018.3)
PyYAML (3.12)
scipy (1.0.0)
setuptools (20.7.0)
six (1.11.0)
tensorflow (1.5.0rc1)
tensorflow-tensorboard (1.5.1)
torch (0.3.0.post4)
torchvision (0.2.0)
unity-lens-photos (1.0)
Werkzeug (0.14.1)
wheel (0.30.0)

ubuntu@lambda-quad:~/installs$ apt list --installed | grep ^python
python/xenial-updates,now 2.7.12-1~16.04 amd64 [installed]
python-all/xenial-updates,now 2.7.12-1~16.04 amd64 [installed,automatic]
python-all-dev/xenial-updates,now 2.7.12-1~16.04 amd64 [installed,automatic]
python-apt/xenial-updates,now 1.1.0~beta1ubuntu0.16.04.1 amd64 [installed]
python-apt-common/xenial-updates,xenial-updates,now 1.1.0~beta1ubuntu0.16.04.1 all [installed]
python-dev/xenial-updates,now 2.7.12-1~16.04 amd64 [installed,automatic]
python-minimal/xenial-updates,now 2.7.12-1~16.04 amd64 [installed]
python-numpy/xenial,now 1:1.11.0-1ubuntu1 amd64 [installed]
python-pip/xenial-updates,xenial-updates,now 8.1.1-2ubuntu0.4 all [installed]
python-pip-whl/xenial-updates,xenial-updates,now 8.1.1-2ubuntu0.4 all [installed,automatic]
python-pkg-resources/xenial,xenial,now 20.7.0-1 all [installed,automatic]
python-setuptools/xenial,xenial,now 20.7.0-1 all [installed,automatic]
python-talloc/xenial,now 2.1.5-2 amd64 [installed]
python-wheel/xenial,xenial,now 0.29.0-1 all [installed,automatic]
python2.7/xenial-updates,now 2.7.12-1ubuntu0~16.04.3 amd64 [installed]
python2.7-dev/xenial-updates,now 2.7.12-1ubuntu0~16.04.3 amd64 [installed,automatic]
python2.7-minimal/xenial-updates,now 2.7.12-1ubuntu0~16.04.3 amd64 [installed]
python3/xenial,now 3.5.1-3 amd64 [installed]
python3-apport/xenial-updates,xenial-updates,now 2.20.1-0ubuntu2.16 all [installed]
python3-apt/xenial-updates,now 1.1.0~beta1ubuntu0.16.04.1 amd64 [installed]
python3-aptdaemon/xenial,xenial,now 1.1.1+bzr982-0ubuntu14 all [installed]
python3-aptdaemon.gtk3widgets/xenial,xenial,now 1.1.1+bzr982-0ubuntu14 all [installed]
python3-aptdaemon.pkcompat/xenial,xenial,now 1.1.1+bzr982-0ubuntu14 all [installed]
python3-blinker/xenial,xenial,now 1.3.dfsg2-1build1 all [installed]
python3-brlapi/xenial-updates,now 5.3.1-2ubuntu2.1 amd64 [installed]
python3-bs4/xenial,xenial,now 4.4.1-1 all [installed]
python3-cairo/xenial,now 1.10.0+dfsg-5build1 amd64 [installed]
python3-cffi-backend/xenial,now 1.5.2-1ubuntu1 amd64 [installed]
python3-chardet/xenial,xenial,now 2.3.0-2 all [installed]
python3-checkbox-support/xenial,xenial,now 0.22-1 all [installed]
python3-commandnotfound/xenial-updates,xenial-updates,now 0.3ubuntu16.04.2 all [installed]
python3-cryptography/xenial-updates,xenial-security,now 1.2.3-1ubuntu0.1 amd64 [installed]
python3-cups/xenial,now 1.9.73-0ubuntu2 amd64 [installed]
python3-cupshelpers/xenial,xenial,now 1.5.7+20160212-0ubuntu2 all [installed]
python3-dbus/xenial,now 1.2.0-3 amd64 [installed]
python3-debian/xenial,xenial,now 0.1.27ubuntu2 all [installed]
python3-defer/xenial,xenial,now 1.0.6-2build1 all [installed]
python3-dev/xenial,now 3.5.1-3 amd64 [installed,automatic]
python3-distupgrade/xenial-updates,xenial-updates,xenial-security,xenial-security,now 1:16.04.25 all [installed]
python3-feedparser/xenial,xenial,now 5.1.3-3build1 all [installed]
python3-gdbm/xenial,now 3.5.1-1 amd64 [installed]
python3-gi/xenial,now 3.20.0-0ubuntu1 amd64 [installed]
python3-gi-cairo/xenial,now 3.20.0-0ubuntu1 amd64 [installed]
python3-guacamole/xenial,xenial,now 0.9.2-1 all [installed]
python3-html5lib/xenial,xenial,now 0.999-4 all [installed]
python3-httplib2/xenial,xenial,now 0.9.1+dfsg-1 all [installed]
python3-idna/xenial,xenial,now 2.0-3 all [installed]
python3-jinja2/xenial,xenial,now 2.8-1 all [installed]
python3-jwt/xenial-updates,xenial-updates,xenial-security,xenial-security,now 1.3.0-1ubuntu0.1 all [installed]
python3-louis/xenial-updates,xenial-updates,xenial-security,xenial-security,now 2.6.4-2ubuntu0.1 all [installed]
python3-lxml/xenial,now 3.5.0-1build1 amd64 [installed]
python3-mako/xenial,xenial,now 1.0.3+ds1-1ubuntu1 all [installed]
python3-markupsafe/xenial,now 0.23-2build2 amd64 [installed]
python3-minimal/xenial,now 3.5.1-3 amd64 [installed]
python3-numpy/xenial,now 1:1.11.0-1ubuntu1 amd64 [installed]
python3-oauthlib/xenial,xenial,now 1.0.3-1 all [installed]
python3-padme/xenial,xenial,now 1.1.1-2 all [installed]
python3-pexpect/xenial,xenial,now 4.0.1-1 all [installed]
python3-pil/xenial-updates,xenial-security,now 3.1.2-0ubuntu1.1 amd64 [installed]
python3-pip/xenial-updates,xenial-updates,now 8.1.1-2ubuntu0.4 all [installed]
python3-pkg-resources/xenial,xenial,now 20.7.0-1 all [installed]
python3-plainbox/xenial,xenial,now 0.25-1 all [installed]
python3-problem-report/xenial-updates,xenial-updates,now 2.20.1-0ubuntu2.16 all [installed]
python3-ptyprocess/xenial,xenial,now 0.5-1 all [installed]
python3-pyasn1/xenial,xenial,now 0.1.9-1 all [installed]
python3-pyatspi/xenial,xenial,now 2.18.0+dfsg-3 all [installed]
python3-pycurl/xenial,now 7.43.0-1ubuntu1 amd64 [installed]
python3-pyparsing/xenial-updates,xenial-updates,now 2.0.3+dfsg1-1ubuntu0.1 all [installed]
python3-renderpm/xenial,now 3.3.0-1 amd64 [installed]
python3-reportlab/xenial,xenial,now 3.3.0-1 all [installed]
python3-reportlab-accel/xenial,now 3.3.0-1 amd64 [installed]
python3-requests/xenial,xenial,now 2.9.1-3 all [installed]
python3-setuptools/xenial,xenial,now 20.7.0-1 all [installed,automatic]
python3-six/xenial,xenial,now 1.10.0-3 all [installed]
python3-software-properties/xenial-updates,xenial-updates,now 0.96.20.7 all [installed]
python3-speechd/xenial,xenial,now 0.8.3-1ubuntu3 all [installed]
python3-systemd/xenial,now 231-2build1 amd64 [installed]
python3-uno/xenial-updates,xenial-security,now 1:5.1.6~rc2-0ubuntu1~xenial3 amd64 [installed]
python3-update-manager/xenial-updates,xenial-updates,xenial-security,xenial-security,now 1:16.04.12 all [installed]
python3-urllib3/xenial-updates,xenial-updates,now 1.13.1-2ubuntu0.16.04.1 all [installed]
python3-wheel/xenial,xenial,now 0.29.0-1 all [installed,automatic]
python3-xdg/xenial,xenial,now 0.25-4 all [installed]
python3-xkit/xenial,xenial,now 0.5.0ubuntu2 all [installed]
python3-xlsxwriter/xenial,xenial,now 0.7.3-1 all [installed]
python3.5/xenial-updates,xenial-security,now 3.5.2-2ubuntu0~16.04.4 amd64 [installed]
python3.5-dev/xenial-updates,xenial-security,now 3.5.2-2ubuntu0~16.04.4 amd64 [installed,automatic]
python3.5-minimal/xenial-updates,xenial-security,now 3.5.2-2ubuntu0~16.04.4 amd64 [installed]

you should update your pytorch to 0.4

Sure enough. Thank you. I’m not a system administrator, so everything takes longer and usually requires wiping out everything and starting over at least once.

import torch
x = torch.empty(5,3)
print(x)
tensor([[ 1.6225e-05, 4.5900e-41, 3.7769e-27],
[ 3.0799e-41, 3.1794e-06, 4.5900e-41],
[ 3.1821e-06, 4.5900e-41, 2.4091e-05],
[ 4.5900e-41, 2.3921e-05, 4.5900e-41],
[ 3.1817e-06, 4.5900e-41, 3.1817e-06]])

rh@lambda-quad:~$ conda create -n pytorch0.4 -c pytorch pytorch=0.4 jupyter torchvision
Solving environment: done

[…]

The following NEW packages will be INSTALLED:
[ … ]
pytorch: 0.4.0-py36_cuda8.0.61_cudnn7.1.2_1 pytorch