Issue with conda settings
Brahmagupta opened this issue · 5 comments
Created conda environment with python=3.7,
I tried all available versions of pytorch=1.3.1 (paired with fixed torchvision=0.4.2 version) with different cudatoolkit versions (9.2, 10.0, 10.1 )
it seems like there's some problem between torchvision0.4.2 and PIL, causing a failure in importing torchvision properly.
Then I tried
conda install pytorch=1.4.1 torchvision cudatoolkit=10.1 -c pytorch
it worked and but the results I got are quite different.
I wonder what pytorch versions and cudatoolkit versions are recommended.
Problem solved by downgrading PIL to a lower version (<7)
#Downgrading PIL
but there's a new issue with loading the pretrained weights..
I'm getting
Traceback (most recent call last):
File "~/anaconda3/envs/chm/lib/python3.7/tarfile.py", line 187, in nti
n = int(s.strip() or "0", 8)
ValueError: invalid literal for int() with base 8: '_tensor_'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "~/anaconda3/envs/chm/lib/python3.7/tarfile.py", line 2289, in next
tarinfo = self.tarinfo.fromtarfile(self)
File "~/anaconda3/envs/chm/lib/python3.7/tarfile.py", line 1095, in fromtarfile
obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
File "~/anaconda3/envs/chm/lib/python3.7/tarfile.py", line 1037, in frombuf
chksum = nti(buf[148:156])
File "~/anaconda3/envs/chm/lib/python3.7/tarfile.py", line 189, in nti
raise InvalidHeaderError("invalid header")
tarfile.InvalidHeaderError: invalid header
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "~/anaconda3/envs/chm/lib/python3.7/site-packages/torch/serialization.py", line 595, in _load
return legacy_load(f)
File "~/anaconda3/envs/chm/lib/python3.7/site-packages/torch/serialization.py", line 506, in legacy_load
with closing(tarfile.open(fileobj=f, mode='r:', format=tarfile.PAX_FORMAT)) as tar, \
File "~/anaconda3/envs/chm/lib/python3.7/tarfile.py", line 1593, in open
return func(name, filemode, fileobj, **kwargs)
File "~/anaconda3/envs/chm/lib/python3.7/tarfile.py", line 1623, in taropen
return cls(name, mode, fileobj, **kwargs)
File "~/anaconda3/envs/chm/lib/python3.7/tarfile.py", line 1486, in __init__
self.firstmember = self.next()
File "~/anaconda3/envs/chm/lib/python3.7/tarfile.py", line 2301, in next
raise ReadError(str(e))
tarfile.ReadError: invalid header
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "../test.py", line 53, in <module>
model.load_state_dict(torch.load(args.load))
File "~/anaconda3/envs/chm/lib/python3.7/site-packages/torch/serialization.py", line 426, in load
return _load(f, map_location, pickle_module, **pickle_load_args)
File "~/anaconda3/envs/chm/lib/python3.7/site-packages/torch/serialization.py", line 599, in _load
raise RuntimeError("{} is a zip archive (did you mean to use torch.jit.load()?)".format(f.name))
RuntimeError: ../../Pretrained/pas_psi.pt is a zip archive (did you mean to use torch.jit.load()?)
Actually, found the solution here Manually Convert the Pretrained Weights to Make it Compatible with Pytorch of Lower Version(<=1.6)
Load the .pt under higher version pytorch and resave it.
However I would recommend including
conda install -c anaconda "pillow<7"
in the conda setting instruction in README
nvm It seems like I downloaded the wrong weights .....