无法在 Docker on Silicon mac 中安装 tensorflow
Can't install tensorflow in Docker on Silicon mac
我想在 M1 Mac 上的 Docker 中安装 tensorflow。
我在 RUN pipenv lock
时出现此错误
#13 3.637 CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement tensorflow (from versions: none)
我只是设置了tensorflow='*',python是3.8,但是找不到tensorflow
我只是想,,,这是因为在硅片上mac? ?或者以我的理解 docker 文件独立于 CPU,是否正确?
Dockerfile
FROM python:3.8
ENV PYTHONUNBUFFERED 1
RUN apt-get update && apt-get install -y netcat
WORKDIR /usr/src/app
COPY .. .
COPY .env.local .env
COPY Pipfile.local Pipfile
RUN pip install --upgrade pip
RUN pip install pipenv
RUN pipenv lock
RUN pipenv install --system
RUN chmod +x entrypoint.local.sh
ENTRYPOINT ["./entrypoint.local.sh"]
Pipfile.local
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
tensorflow = "*"
[dev-packages]
[requires]
python_version = "3.8"
错误日志
#13 0.679 Creating a virtualenv for this project...
#13 0.679 Pipfile: /usr/src/app/Pipfile
#13 0.689 Using /usr/local/bin/python3.8 (3.8.13) to create virtualenv...
⠴ Creating virtual environment...created virtual environment CPython3.8.13.final.0-64 in 366ms
#13 1.128 creator CPython3Posix(dest=/root/.local/share/virtualenvs/app-lp47FrbD, clear=False, no_vcs_ignore=False, global=False)
#13 1.128 seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
#13 1.128 added seed packages: pip==22.0.4, setuptools==62.1.0, wheel==0.37.1
#13 1.128 activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
#13 1.128
#13 1.188✔ Successfully created virtual environment!
#13 1.497 Virtualenv location: /root/.local/share/virtualenvs/app-lp47FrbD
#13 1.512 Locking [dev-packages] dependencies...
#13 1.513 Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
⠙ Locking..✘ Locking Failed!
#13 2.493
#13 2.493 CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement tensorflow (from versions: none)
#13 2.493 [ResolutionFailure]: File "/usr/local/lib/python3.8/site-packages/pipenv/resolver.py", line 822, in _main
#13 2.493 [ResolutionFailure]: resolve_packages(
#13 2.493 [ResolutionFailure]: File "/usr/local/lib/python3.8/site-packages/pipenv/resolver.py", line 771, in resolve_packages
#13 2.493 [ResolutionFailure]: results, resolver = resolve(
#13 2.493 [ResolutionFailure]: File "/usr/local/lib/python3.8/site-packages/pipenv/resolver.py", line 751, in resolve
#13 2.493 [ResolutionFailure]: return resolve_deps(
#13 2.493 [ResolutionFailure]: File "/usr/local/lib/python3.8/site-packages/pipenv/utils/resolver.py", line 1068, in resolve_deps
#13 2.493 [ResolutionFailure]: results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
#13 2.493 [ResolutionFailure]: File "/usr/local/lib/python3.8/site-packages/pipenv/utils/resolver.py", line 862, in actually_resolve_deps
#13 2.493 [ResolutionFailure]: resolver.resolve()
#13 2.493 [ResolutionFailure]: File "/usr/local/lib/python3.8/site-packages/pipenv/utils/resolver.py", line 663, in resolve
#13 2.493 [ResolutionFailure]: raise ResolutionFailure(message=str(e))
#13 2.493 [pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
#13 2.493 You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
#13 2.493 Hint: try $ pipenv lock --pre if it is a pre-release dependency.
#13 2.493 ERROR: No matching distribution found for tensorflow
#13 2.493
尝试在 Dockerfile 中设置平台
FROM --platform=linux/arm64 python:3.8
...
我重现了您的问题,并且能够使用显式 URL 为通用图像构建图像:RUN pipenv install https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.9.0-py3-none-any.whl
并从 Pipfile 中删除 tensorflow
。这是一个 pipenv 问题,与您的 CPU 架构无关,AFAIU。
我想在 M1 Mac 上的 Docker 中安装 tensorflow。
我在 RUN pipenv lock
#13 3.637 CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement tensorflow (from versions: none)
我只是设置了tensorflow='*',python是3.8,但是找不到tensorflow
我只是想,,,这是因为在硅片上mac? ?或者以我的理解 docker 文件独立于 CPU,是否正确?
Dockerfile
FROM python:3.8
ENV PYTHONUNBUFFERED 1
RUN apt-get update && apt-get install -y netcat
WORKDIR /usr/src/app
COPY .. .
COPY .env.local .env
COPY Pipfile.local Pipfile
RUN pip install --upgrade pip
RUN pip install pipenv
RUN pipenv lock
RUN pipenv install --system
RUN chmod +x entrypoint.local.sh
ENTRYPOINT ["./entrypoint.local.sh"]
Pipfile.local
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
tensorflow = "*"
[dev-packages]
[requires]
python_version = "3.8"
错误日志
#13 0.679 Creating a virtualenv for this project...
#13 0.679 Pipfile: /usr/src/app/Pipfile
#13 0.689 Using /usr/local/bin/python3.8 (3.8.13) to create virtualenv...
⠴ Creating virtual environment...created virtual environment CPython3.8.13.final.0-64 in 366ms
#13 1.128 creator CPython3Posix(dest=/root/.local/share/virtualenvs/app-lp47FrbD, clear=False, no_vcs_ignore=False, global=False)
#13 1.128 seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
#13 1.128 added seed packages: pip==22.0.4, setuptools==62.1.0, wheel==0.37.1
#13 1.128 activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
#13 1.128
#13 1.188✔ Successfully created virtual environment!
#13 1.497 Virtualenv location: /root/.local/share/virtualenvs/app-lp47FrbD
#13 1.512 Locking [dev-packages] dependencies...
#13 1.513 Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
⠙ Locking..✘ Locking Failed!
#13 2.493
#13 2.493 CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement tensorflow (from versions: none)
#13 2.493 [ResolutionFailure]: File "/usr/local/lib/python3.8/site-packages/pipenv/resolver.py", line 822, in _main
#13 2.493 [ResolutionFailure]: resolve_packages(
#13 2.493 [ResolutionFailure]: File "/usr/local/lib/python3.8/site-packages/pipenv/resolver.py", line 771, in resolve_packages
#13 2.493 [ResolutionFailure]: results, resolver = resolve(
#13 2.493 [ResolutionFailure]: File "/usr/local/lib/python3.8/site-packages/pipenv/resolver.py", line 751, in resolve
#13 2.493 [ResolutionFailure]: return resolve_deps(
#13 2.493 [ResolutionFailure]: File "/usr/local/lib/python3.8/site-packages/pipenv/utils/resolver.py", line 1068, in resolve_deps
#13 2.493 [ResolutionFailure]: results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
#13 2.493 [ResolutionFailure]: File "/usr/local/lib/python3.8/site-packages/pipenv/utils/resolver.py", line 862, in actually_resolve_deps
#13 2.493 [ResolutionFailure]: resolver.resolve()
#13 2.493 [ResolutionFailure]: File "/usr/local/lib/python3.8/site-packages/pipenv/utils/resolver.py", line 663, in resolve
#13 2.493 [ResolutionFailure]: raise ResolutionFailure(message=str(e))
#13 2.493 [pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
#13 2.493 You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
#13 2.493 Hint: try $ pipenv lock --pre if it is a pre-release dependency.
#13 2.493 ERROR: No matching distribution found for tensorflow
#13 2.493
尝试在 Dockerfile 中设置平台
FROM --platform=linux/arm64 python:3.8
...
我重现了您的问题,并且能够使用显式 URL 为通用图像构建图像:RUN pipenv install https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.9.0-py3-none-any.whl
并从 Pipfile 中删除 tensorflow
。这是一个 pipenv 问题,与您的 CPU 架构无关,AFAIU。