𝘚𝘭𝘰𝘸 𝘣𝘶𝘵 𝘴𝘵𝘦𝘢𝘥𝘺

[기타] The TensorFlow library was compiled to use AVX instructions, but these aren't available on your machine. - Apple Silicon ARM 문제해결 본문

기타

[기타] The TensorFlow library was compiled to use AVX instructions, but these aren't available on your machine. - Apple Silicon ARM 문제해결

.23 2025. 4. 5. 13:53

결론

무지성 pip install 하지말자.

 

문제상황

The TensorFlow library was compiled to use AVX instructions, but these aren't available on your machine.

 

기존 tensorflow 라이브러리를 사용하기 위해서는 본인이 사용하는 CPU가 AVX instruction을 따라야하는데, M1 같은 실리콘 칩은 이를 지원하지 않기 때문에 다른 라이브러리를 사용해야 함.

 

1차 해결방법

기존 tensorflow를 지우고, tensorflow-macos, tensorflow-metal(GPU 가속용, 필수는 아님)를 설치하면 된다.

% pip install tensorflow-macos tensorflow-metal

 

근데?

난 안됐다.

 

저 두 라이브러리를 설치하고 파이썬 들어가서 tensorflow를 import하면

 

RuntimeError: This version of jaxlib was built using AVX instructions, which your CPU and/or operating system do not support. This error is frequently encountered on macOS when running an x86 Python installation on ARM hardware. In this case, try installing an ARM build of Python. Otherwise, you may be able work around this issue by building jaxlib from source.

 

가 뜨면서 파이썬도 같이 영원히 죽어버린다.

 

왜냐면?

홈브루로 설치한 나의 작고 소중한 3.11.11 파이썬 인터프리터가 x86_64(Rosetta) 버전이었기 때문이다.

 

2차 해결방법

% python -c "import platform; print(platform.machine())"

 

터미널켜고 이걸 쳐보면 x86_64 를 출력한다.

 

놀랍게도 파이썬 인터프리터도 인텔용, 맥용이 따로 존재하기 때문에(전 지금알앗다네요) 맥용 파이썬을 설치해주면 된다.

 

실리콘칩 유저들을 위해 파이썬 공식 홈페이지에서 친히 macOS 용 파이썬을 배포해준다.

 

https://www.python.org/downloads/macos/

 

Python Releases for macOS

The official home of the Python Programming Language

www.python.org

 

여기서 깔고싶은 버전 깔아주면 된다.

나는 기존에 쓰던 3.11.11이 없어서, 3.11.7을 다운받았는데(여기서부터 또다른 비극의 시작)

아무튼 alias 설정으로 지금은 행복하게 3.11.7과 3.11.11을 사용할 수 있게 됨

 

그냥 단순히 설치 후 잘 깔렸는지 확인만 하고,

가상환경 설정(강력히 권장)까지 한 다음 다시 1로 돌아가서 tensorflow-macos 를 설치하면 해결된다.

 

그랬더니 딥러닝 코드가 행복하게 잘 돌아간다👍

 

그래서 다시 정리하자면?

 

무지성 pip install 금지.

Comments