可以在Silicon Mac上的Docker中安装Tensorflow
我想在M1 Mac上的Docker中安装TensorFlow。
我有一个错误
#13 3.637 CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement tensorflow (from versions: none)
当运行pipenv lock
我只是设置tensorflow ='*',而python为3.8时, 因为在硅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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我重现了您的问题,并能够使用明确的URL为通用图像构建图像:
运行pipenv install https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow/tensorflow-1.9.0-py3-py3-3--- note-any.whl
并从pipfile中删除tensorflow
。这是一个Pipenv问题,与您的CPU拱门无关。I reproduced your issue and was able to build the image using an explicit URL for a generic image:
RUN pipenv install https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.9.0-py3-none-any.whl
and removingtensorflow
from the Pipfile. This is a pipenv issue and not related to your CPU arch, AFAIU.尝试在dockerfile中设置平台
Try setting your platform in your Dockerfile
如果您想在M1(ARM)Mac上使用Docker中的Tensorflow,并且不想依靠第三方编译的车轮,这是您自己构建轮子的方式(另请参见 repo )。
If you want to use tensorflow in Docker on an M1 (ARM) Mac, and don't want to rely on a wheel compiled by a third party, this is how you build the wheel yourself (see also the repo).