国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

MacOS 系統(tǒng)成功安裝 tensorflow 步驟

這篇具有很好參考價(jià)值的文章主要介紹了MacOS 系統(tǒng)成功安裝 tensorflow 步驟。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

安裝環(huán)境

  • OS Platform and Distribution

macos Ventura 13.1

  • Architecture

Intel x86_64

  • Tensorflow Version

tf 2.11.0

  • Python version

3.9.13

  • Bazel version

5.3.0

  • Xcode version

14.2

從源代碼構(gòu)建

macOS設(shè)置

  • miniconda創(chuàng)建虛擬環(huán)境及tensorflow依賴項(xiàng)安裝
conda create -n tf python==3.9.13
conda activate tf
pip install -U pip numpy wheel
pip install -U keras_preprocessing --no-deps
  • 安裝Bazel
brew install bazel
  • 下載 TensorFlow 源代碼
git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
git checkout r2.11

配置 build

# Check whether script is executing in a VirtualEnv or Conda environment
if [ -z "$VIRTUAL_ENV" ] && [ -z "$CONDA_PREFIX" ] ; then
	echo "VirtualEnv or Conda env is not activated"
	exit -1
fi

# Set the virtual environment path
if ! [ -z "$VIRTUAL_ENV" ] ; then
  VENV_PATH=$VIRTUAL_ENV
elif ! [ -z "$CONDA_PREFIX" ] ; then
  VENV_PATH=$CONDA_PREFIX
fi

# Set the bin and lib directories
VENV_BIN=$VENV_PATH/bin
VENV_LIB=$VENV_PATH/lib

# bazel tf needs these env vars
export PYTHON_BIN_PATH=$VENV_BIN/python
export PYTHON_LIB_PATH=`ls -d $VENV_LIB/*/ | grep python`

# Set the native architecture optimization flag, which is a default
COPT="--copt=-march=native"

# Determine the available features of your CPU
raw_cpu_flags=`sysctl -a | grep machdep.cpu.features | cut -d ":" -f 2 | tr '[:upper:]' '[:lower:]'`

# Append each of your CPU's features to the list of optimization flags
for cpu_feature in $raw_cpu_flags
do
	case "$cpu_feature" in
		"sse4.1" | "sse4.2" | "ssse3" | "fma" | "cx16" | "popcnt" | "maes")
		    COPT+=" --copt=-m$cpu_feature"
		;;
		"avx1.0")
		    COPT+=" --copt=-mavx"
		;;
		*)
			# noop
		;;
	esac
done

echo $COPT

# First ensure a clear working directory in case you've run bazel previously
bazel clean --expunge

# Run TensorFlow configuration (accept defaults unless you have a need)
python configure.py

# Build the TensorFlow pip package
bazel build -c opt $COPT -k //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

安裝測(cè)試軟件包

cd ../
pip uninstall tensorflow  # remove current version

pip install /tmp/tensorflow_pkg/tensorflow-version-tags.whl
python -c "import tensorflow as tf; print(tf.__version__)"

編譯異常處理

1、第三方源碼包無(wú)法下載

  • 問(wèn)題現(xiàn)象:
	Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/XNNPACK/archive/a50369c0fdd15f0f35b1a91c964644327a88d480.zip failed: class java.io.IOException connect timed out
  • 解決方法:

    1. 從該鏈接直接下載文件包,https://github.com/google/XNNPACK/archive/a50369c0fdd15f0f35b1a91c964644327a88d480.zip,(國(guó)內(nèi)下載不了,方法不再贅述)。
    2. 本地搭建http服務(wù)器,用于存放無(wú)法下載的程序包,提供本地下載地址
    3. 修改bzl文件,增加本地鏈接,例如以上鏈接是在tensorflow\tensorflow\workspace2.bzl中

原文內(nèi)容:

tf_http_archive(
    name = "XNNPACK",
    sha256 = "7a16ab0d767d9f8819973dbea1dc45e4e08236f89ab702d96f389fdc78c5855c",
    strip_prefix = "XNNPACK-e8f74a9763aa36559980a0c2f37f587794995622",
    urls = tf_mirror_urls("https://github.com/google/XNNPACK/archive/e8f74a9763aa36559980a0c2f37f587794995622.zip"),
)

替換為:

tf_http_archive(
    name = "XNNPACK",
    sha256 = "ca3a5316b8161214f8f22a578fb638f1fccd0585eee40301363ffd026310379a",
    strip_prefix = "XNNPACK-a50369c0fdd15f0f35b1a91c964644327a88d480",
    urls = ["https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/XNNPACK/archive/a50369c0fdd15f0f35b1a91c964644327a88d480.zip",
            "http://127.0.0.1:8080/tensorflow/XNNPACK-a50369c0fdd15f0f35b1a91c964644327a88d480.zip"
    ],
)

2、Go無(wú)法下載安裝

  • 問(wèn)題現(xiàn)象:

    			Download from https://golang.org/dl/?mode=json&include=all failed: class java.io.IOException connect timed out
    
  • 解決方法:

  1. 該錯(cuò)誤io_bazel_rules_go需要下載go軟件包引起的,需要修改io_bazel_rules_go這個(gè)包中的sdk.bzl文件。從tensorflow\tensorflow\workspace2.bzl中找到這個(gè)包的下載地址,下載到本地,放到本地http服務(wù)器
  2. 修改tensorflow\tensorflow\workspace2.bzl文件,注意sha256也需要修改,可以通過(guò)tensorflow編譯錯(cuò)誤獲取,同時(shí)需要?jiǎng)h除/var/tmp/bazel[loginName]/cache/repos/v1/content_addressable/sha256下面和sha256同名文件,避免無(wú)法使用修改后的文件:

原文內(nèi)容:

	tf_http_archive(
    name = "io_bazel_rules_go",
    sha256 = "80cbfe287bacbe6cec97f0446a413fee7c21dafda3981b9de71a35eebbc89e1f",
    urls = tf_mirror_urls("https://github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip"),
    ],
)



	tf_http_archive(
    name = "io_bazel_rules_go",
    sha256 = "80cbfe287bacbe6cec97f0446a413fee7c21dafda3981b9de71a35eebbc89e1f",
    #urls = tf_mirror_urls("https://github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip"),
    urls = ["http://127.0.0.1:8080/tensorflow/rules_go-v0.34.0.zip"
    ],
)

2、下載go.json文件,放到本地http服務(wù)器,sha256值需要計(jì)算傳入,可以通過(guò)替換bzl中某個(gè)包,讓tensorflow編譯時(shí)報(bào)錯(cuò),提示出該文件的sha256值

3、解壓下載的zip包,打開(kāi) rules*_go-v0.34.0\go\private\sdk.bzl,修改以下內(nèi)容*

原文內(nèi)容:

ctx.download(
            url = [
                "https://golang.org/dl/?mode=json&include=all",
                "https://golang.google.cn/dl/?mode=json&include=all",
            ],
            output = "versions.json",
        )

......

_go_download_sdk = repository_rule(
    implementation = _go_download_sdk_impl,
    attrs = {
        "goos": attr.string(),
        "goarch": attr.string(),
        "sdks": attr.string_list_dict(),
        "urls": attr.string_list(default = ["https://dl.google.com/go/{}"]),
        "version": attr.string(),
        "strip_prefix": attr.string(default = "go"),
    },
)

替換為

ctx.download(
url = [
#"https://golang.org/dl/?mode=json&include=all",
#"https://golang.google.cn/dl/?mode=json&include=all",
"http://127.0.0.1:8080/tensorflow/go.json",
],
output = "versions.json",
sha256 = "47bd74d7eac125a61194d1aa2688c2da3e3bc1bb0981d41a7dd0e9f9cc88d57c",
)

......

_go_download_sdk = repository_rule(
    implementation = _go_download_sdk_impl,
    attrs = {
        "goos": attr.string(),
        "goarch": attr.string(),
        "sdks": attr.string_list_dict(),
        "urls": attr.string_list(default = ["http://127.0.0.1:8080/tensorflow/{}"]),
        "version": attr.string(),
        "strip_prefix": attr.string(default = "go"),
    },
)

4、重新zip壓縮rules_go-v0.34.0.zip,需要根據(jù)編譯錯(cuò)誤提示更改sha256

3、ld: malformed trie, node past end file ‘bazel-out/host/bin/_solib_darwin_x86_64/libtensorflow_Spython_S_Upywrap_Utensorflow_Uinternal.so’

1、該問(wèn)題是由于xcode14升級(jí)引起的,將ld切換成13版本可以暫時(shí)解決該問(wèn)題,查看該鏈接

2、從蘋(píng)果官網(wǎng)下載xcode13,解壓后,將ld拷貝到本機(jī)目錄下,本機(jī)的備份

4、安裝打包好的wheel時(shí),提示:error:tensorflow-*.whl is not suported wheel on this platform

1、tensorflow, 版本不對(duì),目前編譯打包成功的時(shí)v2.11.0版本

2、python版本不對(duì),必須用編譯打包時(shí)使用的python pip安裝

5、dlopen(/Users/davidlaxer/tensorflow-metal/lib/python3.8/site-packages/tensorflow-plugins/libmetal_plugin.dylib, 6): Symbol not found:

1、本地原因是之前安裝了tensorflow-macos,需要卸載之前安裝的所有tensorflow依賴包文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-861185.html

到了這里,關(guān)于MacOS 系統(tǒng)成功安裝 tensorflow 步驟的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • MySql啟動(dòng)錯(cuò)誤(Mac系統(tǒng) 安裝 mysql-8.0.32-macos13-arm64 后每次點(diǎn)擊啟動(dòng) 無(wú)法啟動(dòng)) --- 已解決

    MySql啟動(dòng)錯(cuò)誤(Mac系統(tǒng) 安裝 mysql-8.0.32-macos13-arm64 后每次點(diǎn)擊啟動(dòng) 無(wú)法啟動(dòng)) --- 已解決

    MySql啟動(dòng)的時(shí)候: 立即變紅! 查看日志如下: 2023-03-04T14:18:01.089671Z 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.32) MySQL Community Server - GPL. 2023-03-04T14:18:10.304169Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.32) starting as process 90802 2023-03-04T14:18:10.3

    2023年04月19日
    瀏覽(33)
  • macOS安裝和配置mysql具體步驟

    macOS安裝和配置mysql具體步驟

    ? ? ? ? MySQL是一個(gè)開(kāi)源的關(guān)系數(shù)據(jù)庫(kù)管理系統(tǒng)(RDBMS),廣泛用于構(gòu)建Web應(yīng)用程序和管理大型數(shù)據(jù)集。它使用SQL(結(jié)構(gòu)化查詢語(yǔ)言)作為管理數(shù)據(jù)的主要語(yǔ)言,它因其易用性、可靠性和可擴(kuò)展性而廣受歡迎。MySQL是由Oracle公司開(kāi)發(fā)的,可用于各種操作系統(tǒng),包括Windows、Linux、

    2024年02月12日
    瀏覽(16)
  • MacOS重裝系統(tǒng)的詳細(xì)操作步驟!

    MacOS重裝系統(tǒng)的詳細(xì)操作步驟!

    MacOS重裝和Windows重裝過(guò)程完全不同,但是又有相似的方法。Windows重裝可以保留數(shù)據(jù),也可以不保留;可以打開(kāi)Windows.iso鏡像升級(jí)安裝,也可以使用安裝設(shè)備完全重裝。MacOS重裝系統(tǒng)也有這些對(duì)應(yīng)的選擇。 macOS系統(tǒng)重裝雖說(shuō)有不同的方法,實(shí)際上安裝的界面幾乎相同。一起來(lái)看

    2024年04月12日
    瀏覽(15)
  • 查看mac是macOS x64還是macOS ARM64系統(tǒng)

    查看mac是macOS x64還是macOS ARM64系統(tǒng)

    打開(kāi)終端輸入:

    2024年02月15日
    瀏覽(21)
  • macOS(M系列)安裝BurpSuite 詳細(xì)步驟

    macOS(M系列)安裝BurpSuite 詳細(xì)步驟

    目錄 前言 ?關(guān)于Java環(huán)境部分(進(jìn)入正題) 一 卸載Java環(huán)境 ?二 安裝Java環(huán)境 ?關(guān)于BurpSuite部分(正題分題) 關(guān)于破解部分? 網(wǎng)安人 網(wǎng)安魂 網(wǎng)安都是人上人 正所謂工欲善其事,必先利其器,才有了這篇文章 由于最近換了MacBook Pro(M2芯片),所有工具都要重新安裝,遇到了一

    2024年02月13日
    瀏覽(24)
  • 老Mac電腦安裝macOS Ventura實(shí)戰(zhàn)

    老Mac電腦安裝macOS Ventura實(shí)戰(zhàn)

    前提說(shuō)明:此實(shí)戰(zhàn)適用于老舊Mac電腦(2015年之前的,無(wú)法在系統(tǒng)設(shè)置中升級(jí)macOS Ventura系統(tǒng)的電腦)安裝macOS Ventura系統(tǒng)! 軟件: OpenCore-Patcher-GUI.app.zip? ? 2023年版本v1.2.1已支持 macOS Sonoma new------------2024更新----------------------------- macOS 14.2 系統(tǒng)部分機(jī)型和基于Metal 3802顯卡的機(jī)型

    2024年02月09日
    瀏覽(24)
  • ThinkPad T430 黑蘋(píng)果Hackintosh 使用OpenCore成功安裝macOS 14.3 Sonoma

    ThinkPad T430 黑蘋(píng)果Hackintosh 使用OpenCore成功安裝macOS 14.3 Sonoma

    先放幾張圖,如果有感興趣的,點(diǎn)個(gè)贊再走唄。 有人想看,我才有動(dòng)力去慢慢補(bǔ)文字,講述一下詳細(xì)過(guò)程,寫(xiě)個(gè)教程供大家參考。 過(guò)去一直以為,老電腦只能黑蘋(píng)果低版本的macOS。今天成功安裝了最新的Sonoma,運(yùn)行流暢,連超高清的屏幕保護(hù)都非常絲滑,感覺(jué)不出卡頓。而且

    2024年04月27日
    瀏覽(144)
  • Mac ? 如何在MacOS上安裝pip軟件包

    Mac ? 如何在MacOS上安裝pip軟件包

    以 requests 工具包為例:

    2024年01月18日
    瀏覽(30)
  • 終于,老Mac可以跨級(jí)安裝macOS Ventura了

    幾天前,我在GitHub上看到了一條消息。 開(kāi)發(fā)者Dortania的OpenCore-Legacy-Patcher終于更新了! 開(kāi)發(fā)者在此版本說(shuō)明中寫(xiě)道: OpenCore-Legacy-Patcher終于提供macOS Ventura的測(cè)試版支持了! 喜歡嘗試的果粉可不要錯(cuò)過(guò)! 版本更新日志是這樣寫(xiě)的(翻譯): Ventura特定更新: -解決AMD Polaris外部

    2024年02月04日
    瀏覽(59)
  • 在 macOS 上安裝 Rust 開(kāi)發(fā)環(huán)境并運(yùn)行第一個(gè)程序的詳細(xì)步驟

    首先,打開(kāi)終端并執(zhí)行以下命令來(lái)安裝 Rust 環(huán)境: 該命令將下載并運(yùn)行 Rust 安裝腳本。按照提示完成 Rust 環(huán)境的安裝。 為了確保每次啟動(dòng)終端時(shí)都能加載 Rust 環(huán)境變量,我們需要將以下內(nèi)容添加到 .zshrc 文件中。在終端中執(zhí)行以下命令: 這將在 .zshrc 文件的末尾添加一行代碼

    2024年02月02日
    瀏覽(38)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包