Проблемы с базелем и построением тензорного потока на убунту - PullRequest
0 голосов
/ 09 апреля 2020

Я пытаюсь построить тензор потока в Ubuntu с помощью Bazel, я не смог использовать Bazelisk и Bazel. В установщике есть какая-то глупая ошибка. Мне действительно тяжело из-за ужасной документации по построению тензорного потока из найденного источника здесь

wget https://github.com/bazelbuild/bazel/releases/download/0.27.1/bazel-0.27.1-installer-linux-x86_64.sh
chmod +x bazel-0.27.1-installer-linux-x86_64.sh 
./bazel-0.27.1-installer-linux-x86_64.sh --user
export PATH="$PATH:$HOME/bin"
git clone https://github.com/tensorflow/tensorflow
cd tensorflow
./configure

Out:

INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=80
INFO: Reading rc options for 'version' from /home/emadboctor/tensorflow/.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
ERROR: Unrecognized option: --experimental_repo_remote_exec
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
Traceback (most recent call last):
  File "./configure.py", line 1553, in <module>
    main()
  File "./configure.py", line 1370, in main
    _TF_MAX_BAZEL_VERSION)
  File "./configure.py", line 485, in check_bazel_version
    ['bazel', '--batch', '--bazelrc=/dev/null', 'version'])
  File "./configure.py", line 161, in run_shell
    output = subprocess.check_output(cmd, stderr=stderr)
  File "/usr/lib/python2.7/subprocess.py", line 219, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['bazel', '--batch', '--bazelrc=/dev/null', 'version']' returned non-zero exit status 2

И это продолжает происходить с версии 0.25.1 и 0.19.1

, и когда я пробую эту версию установки:

sudo apt install curl
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
sudo apt update && sudo apt install bazel
sudo apt update && sudo apt full-upgrade
sudo apt install bazel-1.0.0
cd tensorflow 
./configure

Эта проблема возникает:

Traceback (most recent call last):
  File "./configure.py", line 1553, in <module>
    main()
  File "./configure.py", line 1370, in main
    _TF_MAX_BAZEL_VERSION)
  File "./configure.py", line 485, in check_bazel_version
    ['bazel', '--batch', '--bazelrc=/dev/null', 'version'])
  File "./configure.py", line 161, in run_shell
    output = subprocess.check_output(cmd, stderr=stderr)
  File "/usr/lib/python2.7/subprocess.py", line 219, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['bazel', '--batch', '--bazelrc=/dev/null', 'version']' returned non-zero exit status 1

Поэтому я пытаюсь следовать найденному руководству здесь

sudo apt update
sudo apt dist-upgrade
sudo apt install git openjdk-8-jdk curl
sudo apt install python3-dev python3-pip python3-numpy
sudo apt install pkg-config zip g++ zlib1g-dev unzip
wget https://github.com/bazelbuild/bazel/releases/download/0.19.2/bazel-0.19.2-installer-linux-x86_64.sh
chmod +x bazel-0.19.2-installer-linux-x86_64.sh
sudo ./bazel-0.19.2-installer-linux-x86_64.sh
sudo swapoff /swapfile
sudo fallocate -l 16G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
git checkout r2.1

Та же ошибка, что и раньше:

Extracting Bazel installation...
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=80
INFO: Reading rc options for 'version' from /home/emadboctor/tensorflow/.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
ERROR: Unrecognized option: --experimental_repo_remote_exec
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
Traceback (most recent call last):
  File "./configure.py", line 1553, in <module>
    main()
  File "./configure.py", line 1370, in main
    _TF_MAX_BAZEL_VERSION)
  File "./configure.py", line 485, in check_bazel_version
    ['bazel', '--batch', '--bazelrc=/dev/null', 'version'])
  File "./configure.py", line 161, in run_shell
    output = subprocess.check_output(cmd, stderr=stderr)
  File "/usr/lib/python2.7/subprocess.py", line 219, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['bazel', '--batch', '--bazelrc=/dev/null', 'version']' returned non-zero exit status 2

, поэтому я пытаюсь Базелиск ( и это должно установить правильную версию Bazel):

Вот точные шаги:

sudo apt-get update && sudo apt-get upgrade
sudo apt install python-dev python-pip  # or python3-dev python3-pip
pip install -U --user pip six numpy wheel setuptools mock 'future>=0.17.1'
pip install -U --user keras_applications --no-deps
pip install -U --user keras_preprocessing --no-deps

затем я устанавливаю go, используя это

cd /tmp
wget https://dl.google.com/go/go1.11.linux-amd64.tar.gz
sudo tar -xvf go1.11.linux-amd64.tar.gz
sudo mv go /usr/local
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
source ~/.profile

Затем я устанавливаю bazelisk, используя this

go get github.com/bazelbuild/bazelisk
export PATH=$PATH:$(go env GOPATH)/bin

, затем пытаюсь снова настроить:

git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
./configure

Out:

Extracting Bazel installation...
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=80
INFO: Reading rc options for 'version' from /tmp/tensorflow/.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
ERROR: Unrecognized option: --experimental_repo_remote_exec
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
Traceback (most recent call last):
  File "./configure.py", line 1553, in <module>
    main()
  File "./configure.py", line 1370, in main
    _TF_MAX_BAZEL_VERSION)
  File "./configure.py", line 485, in check_bazel_version
    ['bazel', '--batch', '--bazelrc=/dev/null', 'version'])
  File "./configure.py", line 161, in run_shell
    output = subprocess.check_output(cmd, stderr=stderr)
  File "/usr/lib/python2.7/subprocess.py", line 219, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['bazel', '--batch', '--bazelrc=/dev/null', 'version']' returned non-zero exit status 2

Затем я повторяю это , я получаю новую ошибку:

Extracting Bazel installation...
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.19.2 installed.
Please upgrade your bazel installation to version 0.27.1 or higher to build TensorFlow!

Поэтому я устанавливаю 0.27.1 следующим образом:

wget https://github.com/bazelbuild/bazel/releases/download/0.27.1/bazel-0.27.1-installer-linux-x86_64.sh
chmod +x bazel-0.27.1-installer-linux-x86_64.sh
./bazel-0.27.1-installer-linux-x86_64.sh --user
export PATH="$PATH:$HOME/bin"
cd tensorflow
./configure

Я получаю ту же ошибку даже после установки требуемого v ersion

WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.19.2 installed.
Please upgrade your bazel installation to version 0.27.1 or higher to build TensorFlow!

и это вывод bazel version:

Starting local Bazel server and connecting to it...
Build label: 0.19.2
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Nov 19 16:25:09 2018 (1542644709)
Build timestamp: 1542644709
Build timestamp as int: 1542644709

1 Ответ

1 голос
/ 10 апреля 2020

Для проверки исходного кода Tensorflow требуется Bazel 2.0.0 из-за использования флага --experimental_repo_remote_exec.

Также см. https://github.com/tensorflow/tensorflow/issues/37474

Вы почти правильно поняли базилик. go get github.com/bazelbuild/bazelisk устанавливает bazelisk как bazelisk. Вместо этого загрузите bazelisk и создайте символическую ссылку в ~/bin/bazel, чтобы указать bazelisk. Таким образом, скрипт configure TensorFlow может успешно принять bazelisk как bazel.

go get github.com/bazelbuild/bazelisk
mkdir -p ~/bin
ln -s $(go env GOPATH)/bin/bazelisk ~/bin/bazel
export PATH=$HOME/bin:$PATH
...