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

Hi, I am a newbee of pytorch. When I run tutorial like follows:

x = torch.empty(5, 3)
print(x)

I got errors:
Error:module ‘torch’ has no attribute ‘empty’

I type:
x = torch.tensor([5.5, 3])
print(x)

I got error:
‘module’ object is not callable

dose anybody could help me?

You can use that to create tensor, you just can’t print that. You may fix that issue by reinstalling your pytorch.

Hi, which version of pytorch are you using?
These methods have been added in 0.4 and were not present in older versions.

I think I have installed the pytorch of version 0.4.0, but I did not uninstall the older version and I use jupyter notebook, I am not sure when I import torch from it, whats version of the pytorch. Could you give me some suggestion?

You can do print(torch.__version__) to get the current running version.

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.