JETBOT_How to use pytorch?

  1. I am using ‘data_collection’, ‘train_model’, ‘live demo’
  2. Codes are running through jetbots. But, Jetbot GPU training is very slow.
  3. So, I want to use the desktop GPU(or CPU).
  4. I installed ‘python’ and ‘anaconda’. Additionally, installed ‘pytorch(ver.10.1)’
  5. ‘train model.ipynb’ works fine and generates number best_steering_model_xy.pth at desktop
  6. but, ‘live_demo’(is a Road following code) is not working
  7. " model.load_state_dict(torch.load(‘best.pth’)) : An error occurs in this part.
  8. That is

ValueError Traceback (most recent call last)
/usr/lib/python3.6/tarfile.py in nti(s)
188 s = nts(s, “ascii”, “strict”)
–> 189 n = int(s.strip() or “0”, 8)
190 except ValueError:

ValueError: invalid literal for int() with base 8: ‘2\nq\x03((X\x07’

During handling of the above exception, another exception occurred:

InvalidHeaderError Traceback (most recent call last)
/usr/lib/python3.6/tarfile.py in next(self)
2298 try:
-> 2299 tarinfo = self.tarinfo.fromtarfile(self)
2300 except EOFHeaderError as e:

/usr/lib/python3.6/tarfile.py in fromtarfile(cls, tarfile)
1092 buf = tarfile.fileobj.read(BLOCKSIZE)
-> 1093 obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
1094 obj.offset = tarfile.fileobj.tell() - BLOCKSIZE

/usr/lib/python3.6/tarfile.py in frombuf(cls, buf, encoding, errors)
1034
-> 1035 chksum = nti(buf[148:156])
1036 if chksum not in calc_chksums(buf):

/usr/lib/python3.6/tarfile.py in nti(s)
190 except ValueError:
–> 191 raise InvalidHeaderError(“invalid header”)
192 return n

InvalidHeaderError: invalid header

During handling of the above exception, another exception occurred:

ReadError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/torch/serialization.py in _load(f, map_location, pickle_module)
523 try:
–> 524 return legacy_load(f)
525 except tarfile.TarError:

/usr/local/lib/python3.6/dist-packages/torch/serialization.py in legacy_load(f)
447
–> 448 with closing(tarfile.open(fileobj=f, mode=‘r:’, format=tarfile.PAX_FORMAT)) as tar,
449 mkdtemp() as tmpdir:

/usr/lib/python3.6/tarfile.py in open(cls, name, mode, fileobj, bufsize, **kwargs)
1590 raise CompressionError(“unknown compression type %r” % comptype)
-> 1591 return func(name, filemode, fileobj, **kwargs)
1592

/usr/lib/python3.6/tarfile.py in taropen(cls, name, mode, fileobj, **kwargs)
1620 raise ValueError(“mode must be ‘r’, ‘a’, ‘w’ or ‘x’”)
-> 1621 return cls(name, mode, fileobj, **kwargs)
1622

/usr/lib/python3.6/tarfile.py in init(self, name, mode, fileobj, format, tarinfo, dereference, ignore_zeros, encoding, errors, pax_headers, debug, errorlevel, copybufsize)
1483 self.firstmember = None
-> 1484 self.firstmember = self.next()
1485

/usr/lib/python3.6/tarfile.py in next(self)
2310 elif self.offset == 0:
-> 2311 raise ReadError(str(e))
2312 except EmptyHeaderError:

ReadError: invalid header

During handling of the above exception, another exception occurred:

RuntimeError Traceback (most recent call last)
in
----> 1 model.load_state_dict(torch.load(‘best.pth’))

/usr/local/lib/python3.6/dist-packages/torch/serialization.py in load(f, map_location, pickle_module)
366 f = open(f, ‘rb’)
367 try:
–> 368 return _load(f, map_location, pickle_module)
369 finally:
370 if new_fd:

/usr/local/lib/python3.6/dist-packages/torch/serialization.py in _load(f, map_location, pickle_module)
526 if zipfile.is_zipfile(f):
527 # .zip is used for torch.jit.save and will throw an un-pickling error here
–> 528 raise RuntimeError("{} is a zip archive (did you mean to use torch.jit.load()?)".format(f.name))
529 # if not a tarfile, reset file offset and proceed
530 f.seek(0)

RuntimeError: best.pth is a zip archive (did you mean to use torch.jit.load()?)


  1. I think, ‘torch.jit.load’ is not work normally.

  2. How do I solve this problem???

HELP!!!

1 Like