Anyone tried the test code?


#1

Hi there,

I was trying to test if my pytorch is installed correctly on a CentOS-based server. I found there are a set of programs under test dir could do the job. But when I try to run run_test.sh, it always gives me the error message like:

Traceback (most recent call last):
File “test_torch.py”, line 1896, in test_index
self.assertEqual(reference[2, None], reference[2].unsqueeze(0))
TypeError: indexing a tensor with an object of type NoneType. The only supported types are integers, slices, numpy scalars and torch.ByteTensor.

Anyone know what is going on here? I also tried on my mac, and everything works fine.

Thanks!


#2

what is the version of python on the machine, and how did you install pytorch (wheel or conda)?


#3

I use python 2.7 for both mac and centos. They are all installed with conda.


#4

could you get more specific than python 2.7? (what is the subversion).
What is the output of the command:
python --version

Also, if it is installed with conda, then I’m surprised that this failure occurs.
What is your conda version?
Also the output of conda list


#5

Here is the output of python and conda version.
Python 2.7.13 :: Anaconda custom (64-bit)
conda 4.3.13

The output of conda list is:
_license 1.1 py27_1 alabaster 0.7.9 py27_0 anaconda custom py27_0 anaconda-client 1.6.0 py27_0 anaconda-navigator 1.4.3 py27_0 argcomplete 1.0.0 py27_1 astroid 1.4.9 py27_0 astropy 1.3 np112py27_0 babel 2.3.4 py27_0 backports 1.0 py27_0 backports_abc 0.5 py27_0 beautifulsoup4 4.5.3 py27_0 bitarray 0.8.1 py27_0 blaze 0.10.1 py27_0 bokeh 0.12.4 py27_0 boto 2.45.0 py27_0 bottleneck 1.2.0 np112py27_0 bzip2 1.0.6 3 cairo 1.14.8 0 cdecimal 2.3 py27_2 cffi 1.9.1 py27_0 chardet 2.3.0 py27_0 chest 0.2.3 py27_0 click 6.7 py27_0 cloog 0.18.0 0 cloudpickle 0.2.2 py27_0 clyent 1.2.2 py27_0 cmake 3.6.3 0 colorama 0.3.7 py27_0 conda 4.3.13 py27_0 conda-env 2.6.0 0 configobj 5.0.6 py27_0 configparser 3.5.0 py27_0 contextlib2 0.5.4 py27_0 cryptography 1.7.1 py27_0 curl 7.52.1 0 cycler 0.10.0 py27_0 cython 0.25.2 py27_0 cytoolz 0.8.2 py27_0 dask 0.13.0 py27_0 datashape 0.5.4 py27_0 dbus 1.10.10 0 decorator 4.0.11 py27_0 dill 0.2.5 py27_0 docutils 0.13.1 py27_0 entrypoints 0.2.2 py27_0 enum34 1.1.6 py27_0 et_xmlfile 1.0.1 py27_0

thanks!


#6

ohhh, i think i know what’s happening.

You installed pytorch from conda, which installs version 0.1.9, but you are running the tests in master, which assume the master branch of torch.
To run the tests for 0.1.9, you can do:

git clone https://github.com/pytorch/pytorch
cd pytorch
git checkout v0.1.9
cd test
./run_test.sh

#7

Thanks for your help! Now the error is gone.


(dl4daniel) #8

Hi @smth

I ran run_test.sh, got the following error:

ERROR: test_serialization_map_location (__main__.TestTorch)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_torch.py", line 2713, in test_serialization_map_location
    tensor = torch.load(test_file_path, map_location=map_location)
  File "/Users/Natsume/miniconda2/envs/dlnd-tf-lab/lib/python3.5/site-packages/torch/serialization.py", line 222, in load
    return _load(f, map_location, pickle_module)
  File "/Users/Natsume/miniconda2/envs/dlnd-tf-lab/lib/python3.5/site-packages/torch/serialization.py", line 370, in _load
    result = unpickler.load()
AttributeError: Can't get attribute '_rebuild_tensor' on <module 'torch._utils' from '/Users/Natsume/miniconda2/envs/dlnd-tf-lab/lib/python3.5/site-packages/torch/_utils.py'>

In my mac, I ran conda list pytorch , return the following:

pytorch                   0.1.10                   py35_1    soumith

In my downloaded pytorch-master folder, I checked the version inside setup.py and found version = '0.1.10'

How should I solve this error? Thanks!


#9

you are trying to install pytorch via binaries, but run tests for master. See my comment above.


(dl4daniel) #10

@smth Thanks for your reply!

The error is gone with the following method:

  1. git clone
  2. create a new env
  3. conda install numpy setuptools cmake cffi
  4. pip install -r requirements.txt
  5. python setup.py install

then
6. cd test
7../run_test.sh

I don’t why but there is no error this time.

Thanks


(Royi) #11

What if I installed PyTorch using Anaconda (Anaconda Navigator), how can I test the installation?