mirror of
https://github.com/clearml/clearml-agent
synced 2025-02-11 23:34:19 +00:00
Fix PyTorch extra index pip resolver
This commit is contained in:
parent
eefb94d1bc
commit
fb639afcb9
@ -12,8 +12,6 @@ from clearml_agent.session import Session
|
|||||||
|
|
||||||
class SystemPip(PackageManager):
|
class SystemPip(PackageManager):
|
||||||
|
|
||||||
indices_args = None
|
|
||||||
|
|
||||||
def __init__(self, interpreter=None, session=None):
|
def __init__(self, interpreter=None, session=None):
|
||||||
# type: (Optional[Text], Optional[Session]) -> ()
|
# type: (Optional[Text], Optional[Session]) -> ()
|
||||||
"""
|
"""
|
||||||
@ -99,21 +97,19 @@ class SystemPip(PackageManager):
|
|||||||
return Argv(self.bin, '-m', 'pip', '--disable-pip-version-check', *command)
|
return Argv(self.bin, '-m', 'pip', '--disable-pip-version-check', *command)
|
||||||
|
|
||||||
def install_flags(self):
|
def install_flags(self):
|
||||||
if self.indices_args is None:
|
indices_args = tuple(
|
||||||
self.indices_args = tuple(
|
chain.from_iterable(('--extra-index-url', x) for x in PIP_EXTRA_INDICES)
|
||||||
chain.from_iterable(('--extra-index-url', x) for x in PIP_EXTRA_INDICES)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
extra_pip_flags = \
|
extra_pip_flags = \
|
||||||
ENV_PIP_EXTRA_INSTALL_FLAGS.get() or \
|
ENV_PIP_EXTRA_INSTALL_FLAGS.get() or \
|
||||||
self.session.config.get("agent.package_manager.extra_pip_install_flags", None)
|
self.session.config.get("agent.package_manager.extra_pip_install_flags", None)
|
||||||
|
|
||||||
return (self.indices_args + tuple(extra_pip_flags)) if extra_pip_flags else self.indices_args
|
return (indices_args + tuple(extra_pip_flags)) if extra_pip_flags else indices_args
|
||||||
|
|
||||||
def download_flags(self):
|
def download_flags(self):
|
||||||
if self.indices_args is None:
|
indices_args = tuple(
|
||||||
self.indices_args = tuple(
|
chain.from_iterable(('--extra-index-url', x) for x in PIP_EXTRA_INDICES)
|
||||||
chain.from_iterable(('--extra-index-url', x) for x in PIP_EXTRA_INDICES)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
return self.indices_args
|
return indices_args
|
||||||
|
@ -527,6 +527,8 @@ class PytorchRequirement(SimpleSubstitution):
|
|||||||
# return the original line
|
# return the original line
|
||||||
line = req.line
|
line = req.line
|
||||||
|
|
||||||
|
print("PyTorch: Adding index `{}` and installing `{}`".format(extra_index_url[0], line))
|
||||||
|
|
||||||
return line
|
return line
|
||||||
|
|
||||||
except Exception: # noqa
|
except Exception: # noqa
|
||||||
@ -681,7 +683,7 @@ class PytorchRequirement(SimpleSubstitution):
|
|||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
try:
|
try:
|
||||||
if requests.get(torch_url, timeout=10).ok:
|
if requests.get(torch_url, timeout=10).ok:
|
||||||
print('Torch CUDA {} index page found'.format(c))
|
print('Torch CUDA {} index page found, adding `{}`'.format(c, torch_url))
|
||||||
cls.torch_index_url_lookup[c] = torch_url
|
cls.torch_index_url_lookup[c] = torch_url
|
||||||
return cls.torch_index_url_lookup[c], c
|
return cls.torch_index_url_lookup[c], c
|
||||||
except Exception:
|
except Exception:
|
||||||
|
Loading…
Reference in New Issue
Block a user