Li_Rong
(Li Rong)
May 10, 2018, 9:29am
1
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?
11177
(聂浩)
May 10, 2018, 9:32am
2
You can use that to create tensor, you just can’t print that. You may fix that issue by reinstalling your pytorch.
albanD
(Alban D)
May 10, 2018, 9:38am
3
Hi, which version of pytorch are you using?
These methods have been added in 0.4 and were not present in older versions.
Li_Rong
(Li Rong)
May 10, 2018, 9:40am
4
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?
albanD
(Alban D)
May 10, 2018, 9:43am
5
You can do print(torch.__version__)
to get the current running version.
Li_Rong
(Li Rong)
May 10, 2018, 9:46am
6
it shows version is 0.1.12, how I let jupyter import torch of 0.4.0?
thank you…
albanD
(Alban D)
May 10, 2018, 10:18am
7
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)
Li_Rong
(Li Rong)
May 10, 2018, 11:28am
8
I run the command and it return me a path as follows:
/home/user/anaconda3/bin/python
albanD
(Alban D)
May 10, 2018, 12:00pm
9
Then you need to use conda
to install the new pytorch.
Li_Rong
(Li Rong)
May 10, 2018, 12:03pm
10
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
albanD
(Alban D)
May 10, 2018, 12:15pm
11
As answered in your other post, most certainly an old conda install.
Li_Rong
(Li Rong)
May 10, 2018, 12:33pm
12
OK, thank you. I will try.
Li_Rong
(Li Rong)
May 10, 2018, 12:48pm
13
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.
albanD
(Alban D)
May 10, 2018, 12:53pm
14
I don’t know what it is then
Someone that knows conda better might be able to help.
Li_Rong
(Li Rong)
May 10, 2018, 1:06pm
15
any way, thank you again.
Which conda version do you have?
You can check if with conda --version
.
Li_Rong
(Li Rong)
May 11, 2018, 12:02am
17
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?
Li_Rong
(Li Rong)
May 11, 2018, 12:42am
19
ok, I will try. thank you!
Li_Rong
(Li Rong)
May 11, 2018, 12:52am
20
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.