Skip to content

Commit

Permalink
https://tensorflow.google.cn/install/source_windows #注意该页面应使用英文,中文的话可…
Browse files Browse the repository at this point in the history
…能是老版本的步骤

bazel clean --expunge

可根据.bazelversion下载bazel版本

set http_proxy=http://127.0.0.1:10809
set https_proxy=http://127.0.0.1:10809

bazel --output_user_root="E:/bazel_root" build --noincompatible_do_not_split_linking_cmdline --config=windows --config=win_clang --verbose_failures --config=opt [--config=dbg] --local_ram_resources=2048
■//tensorflow:tensorflow.dll //tensorflow:tensorflow.lib //tensorflow:install_headers
■//tensorflow:tensorflow_cc(在版本2.16.1失败,提示链接时找不到导入函数)
■//tensorflow/examples/label_image(例子)
■//tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tensorflow_cpu

# 注意: 由于windows系统文件路径长度限制,需要设置output_user_root
# 注意: 如果在windows系统使用pyenv配置python,编译(bazel build ...)时会提示CreateProcessW(python3...)失败(ERROR: src/main/native/windows/process.cc(202))
原因是找到的python3可执行脚本是linux的,需要修改"~\_bazel_Administrator\brzvmudz\external\llvm-raw\utils\bazel\configure.bzl"
...
python_bin = repository_ctx.which("python3") 改为 python_bin = repository_ctx.which("python3.bat")
...
  • Loading branch information
sjhgithub committed Jun 13, 2024
1 parent 675237f commit 67c7bf8
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 1 deletion.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ build:win_clang --host_platform=//tensorflow/tools/toolchains/win:x64_windows-cl
build:win_clang --compiler=clang-cl
build:win_clang --linkopt=/FORCE:MULTIPLE
build:win_clang --host_linkopt=/FORCE:MULTIPLE
build:win_clang --linkopt=/pdbpagesize:8192
test:win_clang --linkopt=/FORCE:MULTIPLE
test:win_clang --host_linkopt=/FORCE:MULTIPLE

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ node_modules
*.pyc
__pycache__
*.swp
.vscode/
#.vscode/
cmake_build/
tensorflow/contrib/cmake/_build/
.idea/**
Expand Down
56 changes: 56 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(msvc) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/bazel-bin/tensorflow/examples/label_image/label_image.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "integratedTerminal",
"preLaunchTask": "bazel build"
},
{
"name": "(lldb) Launch",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/bazel-bin/tensorflow/examples/label_image/label_image.exe",
"args": [],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"preLaunchTask": "bazel build"
},
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bazel-bin/tensorflow/examples/label_image/label_image.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "D:/msys64/mingw64/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "bazel build"
}
]
}
37 changes: 37 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"tasks": [
// try bazel build
{
"type": "cppbuild",
"label": "bazel build",
"command": "bazel",
"args": [
"--output_user_root=\"E:/bazel_root\"",
"build",
"--noincompatible_do_not_split_linking_cmdline",
"--config=windows",
"--config=win_clang",
//"--config=win_mingw",
//"--config=win_msys",
//"-s",
"--verbose_failures",
"--config=opt",
//"--config=dbg",
"--local_ram_resources=2048",
"//tensorflow/examples/label_image"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
28 changes: 28 additions & 0 deletions bazel_build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@echo off
@chcp 936

SET CC1=win_clang
SET CC2=win_mingw
SET CC3=win_msys
SET ROT=E:/bazel_root
SET TGT=//tensorflow:tensorflow.dll //tensorflow:tensorflow.lib //tensorflow:install_headers //tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tf_nightly_cpu //tensorflow/lite:tensorflowlite //tensorflow/lite/delegates/flex:tensorflowlite_flex
SET CMD=bazel --output_user_root="%ROT%" build --noincompatible_do_not_split_linking_cmdline --config=windows --config=%CC1% --verbose_failures --config=opt --local_ram_resources=2048

echo --------------------------------------------------------
echo ----------------------Debug-----------------------------
echo --------------------------------------------------------
echo %CMD% --config=dbg %TGT%
echo --------------------------------------------------------
echo ---------------------Release----------------------------
echo --------------------------------------------------------
echo %CMD% %TGT%
echo --------------------------------------------------------
echo ----------------------Debug-----------------------------
echo --------------------------------------------------------
%CMD% --config=dbg %TGT%
echo --------------------------------------------------------
echo ---------------------Release----------------------------
echo --------------------------------------------------------
%CMD% %TGT%

pause

0 comments on commit 67c7bf8

Please sign in to comment.