Error:module 'torch' has no attribute 'empty'

it shows version is 0.1.12, how I let jupyter import torch of 0.4.0?
thank you…

You should remove and reinstall the new pytorch version for the python that jupyter uses.
You can check which python is used in jupyter by running:

import sys
print(sys.executable)

I run the command and it return me a path as follows:
/home/user/anaconda3/bin/python

Then you need to use conda to install the new pytorch.

but when I use conda to install the new version pytorch, it shows that the version of
0.2.0 will be installed but not 0.4.0, as follows:

user@user-Server:~/anaconda3/lib/python3.5/site-packages$ conda install pytorch torchvision -c pytorch
Fetching package metadata …
Solving package specifications: .

Package plan for installation in environment /home/user/anaconda3:

The following NEW packages will be INSTALLED:

pytorch:     0.2.0-py35hb1547bd_4cu80 soumith [cuda80]
torchvision: 0.1.9-py35h72e4c6f_1     soumith

Proceed ([y]/n)? n

I do not know what’s wrong

As answered in your other post, most certainly an old conda install.

OK, thank you. I will try.

I have updated conda using command as follows:
conda update conda

and then install pytorch using command:
conda install pytorch torchvision -c pytorch

but I got the same result. It still
shows that 0.2.0 version will be installed.

I don’t know what it is then :confused:
Someone that knows conda better might be able to help.

any way, thank you again.

Which conda version do you have?
You can check if with conda --version.

I have checked conda version,which is conda 4.3.30

It looks like it’s ~6 months old (source).
I have 4.4.7 installed. Could you run conda update conda again and post the output?

ok, I will try. thank you!

I just run conda update conda, and I found that I still update to 4.3.30, like follows:

user@user-Server:~/workspace$ conda update conda
Fetching package metadata …
Solving package specifications: .

All requested packages already installed.

packages in environment at /home/user/anaconda3:

conda 4.3.30 py35hf9359ed_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

I think that maybe the conda updated from a mirror website.

I’m not sure, if the mirror might be the issue.
Could you try to re-install it using the latest package?

I have installed pytorch 0.4.0 now, but when I run code :
x = torch.empty(5, 3)
print (x)

it also have errors as follows:

RuntimeError Traceback (most recent call last)
in ()
1 x = torch.empty(5, 3)
----> 2 print ( x )

/home/user/anaconda3/lib/python3.5/site-packages/torch/tensor.py in repr(self)
55 # characters to replace unicode characters with.
56 if sys.version_info > (3,):
—> 57 return torch._tensor_str._str(self)
58 else:
59 if hasattr(sys.stdout, ‘encoding’):

/home/user/anaconda3/lib/python3.5/site-packages/torch/_tensor_str.py in _str(self)
216 suffix = ‘, dtype=’ + str(self.dtype) + suffix
217
–> 218 fmt, scale, sz = _number_format(self)
219 if scale != 1:
220 prefix = prefix + SCALE_FORMAT.format(scale) + ’ ’ * indent

/home/user/anaconda3/lib/python3.5/site-packages/torch/_tensor_str.py in _number_format(tensor, min_sz)
94 # TODO: use fmod?
95 for value in tensor:
—> 96 if value != math.ceil(value.item()):
97 int_mode = False
98 break

RuntimeError: Overflow when unpacking long

could you help me?

This seems to be a bug when trying to print an empty Tensor.
@richard explained it here.

I see, thank you very much!

adding “python.linting.pylintPath”:“E:\ProgramFiles\Anaconda3\pkgs\pylint-1.8.2-py36_0\Scripts\pylint” in setting.json will help.