Tensorflow not found on pip install inside Docker Container using Mac M1

2024/9/21 21:41:36

I'm trying to run some projects using the new Mac M1. Those projects already work on Intel processor and are used by other developers that use Intel.

I am not able to build this simple Dockerfile:

FROM python:3.9RUN python -m pip install --upgrade pipRUN pip install tensorflow==2.6.2

I get this message:

 > [3/3] RUN pip install tensorflow==2.6.2:                                                                                                            
#6 0.583 ERROR: Could not find a version that satisfies the requirement tensorflow==2.6.2 (from versions: none)                                        
#6 0.583 ERROR: No matching distribution found for tensorflow==2.6.2  

I am able to install tensorflow locally, outside of the Dockerfile. Also, friends are able to build this image from their intel Mac.

I even tried to run docker build com different console architectures: i386 and arm64, but none work.

Any suggestions?

Answer

EDIT: you may want to check menrfa's answer by looking at https://github.com/KumaTea/tensorflow-aarch64


The package tensorflow is not available for armv8.

I'll guessing your local python is running using rosetta2 (intel x86_64). You can check that using:

python3 -c "import platform; print(platform.machine())"
x86_64

The solution is forcing Docker to build that image for x86_64 also. It's easy. Just change your Dockerfile to:

FROM --platform=linux/x86_64 python:3.9RUN python -m pip install --upgrade pipRUN pip install tensorflow==2.6.2

Or, if you do not want to change your Dockerfile, you may build that image with:

docker build --platform linux/x86_64 -t myimage .

post note:

as [tyrex] said in a comment, although the tensorflow gets installed on the armv8, it will probably fail due to some bugs on the emulation (eg qemu: uncaught target signal 6 (Aborted) - core dumped).

He solved his requirements using PyTorch instead.

https://en.xdnf.cn/q/72015.html

Related Q&A

Fast fuse of close points in a numpy-2d (vectorized)

I have a question similar to the question asked here: simple way of fusing a few close points. I want to replace points that are located close to each other with the average of their coordinates. The c…

I use to_gbq on pandas for updating Google BigQuery and get GenericGBQException

While trying to use to_gbq for updating Google BigQuery table, I get a response of:GenericGBQException: Reason: 400 Error while reading data, error message: JSON table encountered too many errors, givi…

Something wrong with Keras code Q-learning OpenAI gym FrozenLake

Maybe my question will seem stupid.Im studying the Q-learning algorithm. In order to better understand it, Im trying to remake the Tenzorflow code of this FrozenLake example into the Keras code.My code…

How to generate month names as list in Python? [duplicate]

This question already has answers here:Get month name from number(18 answers)Closed 2 years ago.I have tried using this but the output is not as desired m = [] import calendar for i in range(1, 13):m.a…

Getting ERROR: Double requirement given: setuptools error in zappa

I tried to deploy my Flask app with zappa==0.52.0, but I get an error as below;ERROR: Double requirement given: setuptools (already in setuptools==52.0.0.post20210125, name=setuptools) WARNING: You are…

PySpark - Create DataFrame from Numpy Matrix

I have a numpy matrix:arr = np.array([[2,3], [2,8], [2,3],[4,5]])I need to create a PySpark Dataframe from arr. I can not manually input the values because the length/values of arr will be changing dyn…

RunTimeError during one hot encoding

I have a dataset where class values go from -2 to 2 by 1 step (i.e., -2,-1,0,1,2) and where 9 identifies the unlabelled data. Using one hot encode self._one_hot_encode(labels)I get the following error:…

Is there a Mercurial or Git version control plugin for PyScripter? [closed]

Closed. This question is seeking recommendations for books, tools, software libraries, and more. It does not meet Stack Overflow guidelines. It is not currently accepting answers.We don’t allow questi…

How to make a color map with many unique colors in seaborn

I want to make a colormap with many (in the order of hundreds) unique colors. This code: custom_palette = sns.color_palette("Paired", 12) sns.palplot(custom_palette)returns a palplot with 12 …

Swap column values based on a condition in pandas

I would like to relocate columns by condition. In case country is Japan, I need to relocate last_name and first_name reverse.df = pd.DataFrame([[France,Kylian, Mbappe],[Japan,Hiroyuki, Tajima],[Japan,…