Given I installed pytorch by conda install pytorch torchvision -c soumith
The problem 1
_rebuild_tensor
inside _utils/
does not in the following output, why is it?
", ".join([t for t in dir(torch._utils)])
### inside _utils we have the following function, but why not shown up???
# def _rebuild_tensor(storage, storage_offset, size, stride):
# class_name = storage.__class__.__name__.replace('Storage', 'Tensor')
# module = importlib.import_module(storage.__module__)
# tensor_class = getattr(module, class_name)
# return tensor_class().set_(storage, storage_offset, size, stride)
# output is the following
# '__builtins__, __cached__, __doc__, __file__, __loader__, __name__, __package__, __spec__,
# _accumulate, _cuda, _import_dotted_name, _range, _type, torch'
The problem 2
_rebuild_tensor
inside _utils/
does not in the following output, given it is imported inside torch.tensor.py
file, why is it?
", ".join([t for t in dir(torch.tensor)])
# output is the following
# '_TensorBase, __builtins__, __cached__, __doc__, __file__, __loader__, __name__, __package__,
# __spec__, _cuda, _range, _tensor_str, _type, sys, torch'
I think the two problems above is really the same one, that I can’t have access to torch._utils._rebuild_tensor
, I wonder why.
Guesses
- I just did
conda install pytorch torchvision -c soumith
to install, was this the problem? - when I ran
./run_test.sh
, I got the following error:
ERROR: test_serialization_map_location (__main__.TestTorch)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_torch.py", line 2711, 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'>
Solution worked this time
- git clone pytorch
- create a new env
- conda install numpy setuptools cmake cffi
- pip install -r requirements.txt
- python setup.py install
but the 5th step has a lot of failures and warnings, I can’t runimport torch
then I did -
pip install -e .
then I can runimport torch
and the problems above are gone.
but when I runcd test/
and./run_test.sh
, previous error is gone, but I got the following Exception:
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x114c5da60>
Traceback (most recent call last):
File "/Users/Natsume/miniconda2/envs/pytorch-experiment/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable
should I be worried about this one?
Thanks a lot!