Key Error while installing pytorch with cuda

I am getting 2 errors. The first is Key Error and the other is Memory Error.

C:\Users\91781>pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio===0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
Collecting torch==1.8.0+cu111
Downloading https://download.pytorch.org/whl/cu111/torch-1.8.0%2Bcu111-cp38-cp38-win_amd64.whl (3055.7 MB)
|████████████████████████████████| 3055.7 MB 450 bytes/s eta 0:00:12ERROR: Exception:
Traceback (most recent call last):
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\resolvelib\resolvers.py”, line 171, in _merge_into_criterion
crit = self.state.criteria[name]
KeyError: ‘torch’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\cli\base_command.py”, line 189, in _main
status = self.run(options, args)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\cli\req_command.py”, line 178, in wrapper
return func(self, options, args)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\commands\install.py”, line 316, in run
requirement_set = resolver.resolve(
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\resolution\resolvelib\resolver.py”, line 121, in resolve
self._result = resolver.resolve(
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\resolvelib\resolvers.py”, line 453, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\resolvelib\resolvers.py”, line 318, in resolve
name, crit = self._merge_into_criterion(r, parent=None)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\resolvelib\resolvers.py”, line 173, in _merge_into_criterion
crit = Criterion.from_requirement(self._p, requirement, parent)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\resolvelib\resolvers.py”, line 82, in from_requirement
if not cands:
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\resolvelib\structs.py”, line 124, in bool
return bool(self._sequence)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py”, line 143, in bool
return any(self)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py”, line 38, in _iter_built
candidate = func()
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\resolution\resolvelib\factory.py”, line 167, in _make_candidate_from_link
self._link_candidate_cache[link] = LinkCandidate(
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\resolution\resolvelib\candidates.py”, line 300, in init
super().init(
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\resolution\resolvelib\candidates.py”, line 144, in init
self.dist = self._prepare()
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\resolution\resolvelib\candidates.py”, line 226, in _prepare
dist = self._prepare_distribution()
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\resolution\resolvelib\candidates.py”, line 311, in _prepare_distribution
return self._factory.preparer.prepare_linked_requirement(
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\operations\prepare.py”, line 457, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\operations\prepare.py”, line 480, in _prepare_linked_requirement
local_file = unpack_url(
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\operations\prepare.py”, line 230, in unpack_url
file = get_http_url(
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\operations\prepare.py”, line 108, in get_http_url
from_path, content_type = download(link, temp_dir.path)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\network\download.py”, line 163, in call
for chunk in chunks:
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\cli\progress_bars.py”, line 159, in iter
for x in it:
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_internal\network\utils.py”, line 64, in response_chunks
for chunk in response.raw.stream(
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\urllib3\response.py”, line 576, in stream
data = self.read(amt=amt, decode_content=decode_content)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\urllib3\response.py”, line 519, in read
data = self._fp.read(amt) if not fp_closed else b""
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\cachecontrol\filewrapper.py”, line 65, in read
self._close()
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\cachecontrol\filewrapper.py”, line 52, in _close
self.__callback(self._buf.getvalue())
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\cachecontrol\controller.py”, line 309, in cache_response
cache_url, self.serializer.dumps(request, response, body=body)
File “c:\users\91781\appdata\local\programs\python\python38\lib\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 "c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\msgpack_init
.py", line 35, in packb
return Packer(**kwargs).pack(o)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\msgpack\fallback.py”, line 960, in pack
self._pack(obj)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\msgpack\fallback.py”, line 943, in _pack
return self._pack_map_pairs(
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\msgpack\fallback.py”, line 1045, in _pack_map_pairs
self._pack(v, nest_limit - 1)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\msgpack\fallback.py”, line 943, in _pack
return self._pack_map_pairs(
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\msgpack\fallback.py”, line 1044, in _pack_map_pairs
self._pack(k, nest_limit - 1)
File “c:\users\91781\appdata\local\programs\python\python38\lib\site-packages\pip_vendor\msgpack\fallback.py”, line 896, in _pack
return self._buffer.write(obj)
MemoryError

The other exception is the Memory error.

1 Like

hey everyone,
i got same error while installing pytorch with cuda
if anyone knows or have solved the issue do let us know

Here pip tries to load pre-downloaded files.

Instead of using

pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio===0.8.0 -f https://download.pytorch.org/whl/torch_stable.html

We use

pip --no-cache-dir install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio===0.8.0 -f https://download.pytorch.org/whl/torch_stable.html --user

This overrides the pre-downloaded files and starts from scratch.

1 Like