MemoryError with Paperspace for Fastbook Pip Install

So I recently was trying to run the FastAI notebook #2 when I ran into problems from the getgo (I am using a Paperspace GPU P5000). Namely I think the issue is trying to install the fastbook module via pip, here is the code:

!pip install -Uqq fastbook
import fastbook
fastbook.setup_book()

And here is the error that comes with it:

ERROR: Exception:
Traceback (most recent call last):
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 216, in _main
    status = self.run(options, args)
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
    return func(self, options, args)
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 324, in run
    requirement_set = resolver.resolve(
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py", line 183, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py", line 388, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py", line 340, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 467, in prepare_linked_requirement
    local_file = unpack_url(
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 255, in unpack_url
    file = get_http_url(
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 129, in get_http_url
    from_path, content_type = _download_http_url(
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 282, in _download_http_url
    for chunk in download.chunks:
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_internal/network/utils.py", line 64, in response_chunks
    for chunk in response.raw.stream(
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 65, in read
    self._close()
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 52, in _close
    self.__callback(self.__buf.getvalue())
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_vendor/cachecontrol/controller.py", line 309, in cache_response
    cache_url, self.serializer.dumps(request, response, body=body)
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_vendor/cachecontrol/serialize.py", line 72, in dumps
    return b",".join([b"cc=4", msgpack.dumps(data, use_bin_type=True)])
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_vendor/msgpack/__init__.py", line 35, in packb
    return Packer(**kwargs).pack(o)
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 936, in pack
    self._pack(obj)
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 919, in _pack
    return self._pack_map_pairs(
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 1021, in _pack_map_pairs
    self._pack(v, nest_limit - 1)
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 919, in _pack
    return self._pack_map_pairs(
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 1021, in _pack_map_pairs
    self._pack(v, nest_limit - 1)
  File "/opt/conda/envs/fastai/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 865, in _pack
    return self._buffer.write(obj)
MemoryError

Any idea how to resolve this?

P.S. I see functions of util.py being used but not being imported, how does that work?

Hi @robmel,

Have you tried to simply do :

import fastbook

If I remember correctly, you already have fastai, fastbook and pytorch preinstalled. The functions may have been imported during the initialisation of the notebook.

Hope it helps !
Charles

1 Like

Thanks that works, I wonder why the boilerplate at the top of the notebook then.

Because not everybody is using a preconfigured Gradient instance. :slight_smile: Glad it worked.

2 Likes