可以在Silicon Mac上的Docker中安装Tensorflow

发布于 2025-01-26 07:54:01 字数 4146 浏览 5 评论 0 原文

我想在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 

I want to install tensorflow in Docker on M1 Mac.

I have this error when 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)

I simply set tensorflow='*' and python is 3.8, but it cant' find the tensorflow I just wonder,,, it is because on silicon mac?? or in my understanding docker file is independent from CPU, is it correct?

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"

error log

#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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

葬花如无物 2025-02-02 07:54:01

我重现了您的问题,并能够使用明确的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 removing tensorflow from the Pipfile. This is a pipenv issue and not related to your CPU arch, AFAIU.

剑心龙吟 2025-02-02 07:54:01

尝试在dockerfile中设置平台

FROM --platform=linux/arm64 python:3.8
...

Try setting your platform in your Dockerfile

FROM --platform=linux/arm64 python:3.8
...
_蜘蛛 2025-02-02 07:54:01

如果您想在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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文