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/ 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/ in next(self)
2298 try:
-> 2299 tarinfo = self.tarinfo.fromtarfile(self)
2300 except EOFHeaderError as e:

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

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

/usr/lib/python3.6/ 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/ 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/ in legacy_load(f)
–> 448 with closing(, mode=‘r:’, format=tarfile.PAX_FORMAT)) as tar,
449 mkdtemp() as tmpdir:

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

/usr/lib/python3.6/ 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)

/usr/lib/python3.6/ 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 =

/usr/lib/python3.6/ 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)
----> 1 model.load_state_dict(torch.load(‘best.pth’))

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

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???


1 Like