bazel编译im2txt的问题
问题:
原本可以正常运行的程序,出现找不到tensorflow的问题。打印出来sys.version和sys.path,发现python版本并不是conda环境的版本
(tensorflow) yuany@hp-obelisk-desktop:~/AI/im2txt$ sh training.sh
INFO: Analyzed 17 targets (1 packages loaded, 2 targets configured).
INFO: Found 17 targets...
INFO: Elapsed time: 0.062s, Critical Path: 0.01s
INFO: 0 processes.
INFO: Build completed successfully, 9 total actions
3.6.8 (default, Aug 20 2019, 17:12:48)
[GCC 8.3.0]
['/home/yuany/AI/im2txt/im2txt', '/home/yuany/AI/im2txt/bazel-bin/im2txt/train.runfiles', '/home/yuany/AI/im2txt/bazel-bin/im2txt/train.runfiles/im2txt', '/home/yuany/AI/im2txt/bazel-bin/im2txt/train.runfiles/bazel_tools', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']
--------------------------------
Traceback (most recent call last):
File "/home/yuany/AI/im2txt/bazel-bin/im2txt/train.runfiles/im2txt/im2txt/train.py", line 25, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
直接运行im2txt子目录下的python文件,却可以正确使用anaconda环境中的python2.7
(tensorflow) yuany@hp-obelisk-desktop:~/AI/im2txt$ python im2txt/train.py
2.7.16 |Anaconda, Inc.| (default, Aug 22 2019, 16:00:36)
[GCC 7.3.0]
['/home/yuany/AI/im2txt/im2txt', '/home/yuany/anaconda3/envs/tensorflow/lib/python27.zip', '/home/yuany/anaconda3/envs/tensorflow/lib/python2.7', '/home/yuany/anaconda3/envs/tensorflow/lib/python2.7/plat-linux2', '/home/yuany/anaconda3/envs/tensorflow/lib/python2.7/lib-tk', '/home/yuany/anaconda3/envs/tensorflow/lib/python2.7/lib-old', '/home/yuany/anaconda3/envs/tensorflow/lib/python2.7/lib-dynload', '/home/yuany/anaconda3/envs/tensorflow/lib/python2.7/site-packages', '/home/yuany/anaconda3/envs/tensorflow/lib/python2.7/site-packages/PIL']
--------------------------------
Traceback (most recent call last):
File "im2txt/train.py", line 27, in <module>
from im2txt import configuration
ImportError: No module named im2txt
所以怀疑是bazel编译出现了问题。因为training.sh中有这么两步跟bazel有关。
# Build the model.
#cd research/im2txt
bazel build -c opt //im2txt/... # Run the training script.
bazel-bin/im2txt/train \
--input_file_pattern="${MSCOCO_DIR}/train-?????-of-00256" \
--inception_checkpoint_file="${INCEPTION_CHECKPOINT}" \
--train_dir="${MODEL_DIR}/train" \
--train_inception=false \
--number_of_steps=1000000
最后找到的原因是bazel版本升级了,把默认的python版本换成了3。 用一个低一点儿的bazel版本编译,就可以正常运行了。详细的应该也可以通过设置编译参数来指定用python2,但我并没有尝试。
https://github.com/bazelbuild/bazel/issues/7359
As of 0.24, py_binary and py_test targets that do not specify a python_version attribute (formerly called default_python_version) will use PY3 instead of PY2 when --incompatible_py3_is_default is enabled. In addition, --incompatible_py3_is_default makes the host configuration use PY3 instead of PY2, unless --host_force_python=PY2 is given to override this behavior. --incompatible_py3_is_default requires that --incompatible_allow_python_version_transitions is set true, or else an error is raised. This means that if you opt out of --incompatible_allow_python_version_transitions during the migration window, you should also opt out of --incompatible_py3_is_default.
https://github.com/tensorflow/lingvo/issues/113
卸载bazel
rm -rf ~/.bazel
rm -rf ~/bin
rm -rf /usr/bin/bazel
注释~/.bashrc 中bazel的环境变量
bazel编译im2txt的问题的更多相关文章
- Bazel 编译工具; tensorflow 编译
什么是bazel https://docs.bazel.build/versions/master/bazel-overview.html 使用 bazel 构建 c++ 工程 https://git ...
- 开源框架---通过Bazel编译使用tensorflow c++ API 记录
开源框架---通过Bazel编译使用tensorflow c++ API 记录 tensorflow python API,在python中借用pip安装tensorflow,真的很方便,几句指令就完 ...
- TensorFlow入门——bazel编译(带GPU)
这一系列基本上是属于我自己进行到了那个步骤就做到那个步骤的 由于新装了GPU (GTX750ti)和CUDA9.0.CUDNN7.1版本的软件,所以希望TensorFlow能在GPU上运行,也算上补上 ...
- Ubuntu系统下Bazel编译Tensorflow环境
编写此文主要为了介绍在Ubuntu16.04上搭建Tensorflow-lite编译环境,涉及目标硬件为Armv7架构,8核Cortex-A7. 1.开发环境介绍: OS:Ubuntu16.04 64 ...
- bazel编译tensorflow 生成libtensorflow_inference.so 和 libandroid_tensorflow_inference_java.jar
bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//externa ...
- Redhat环境下编译安装Google Bazel
Redhat环境下编译安装bazel 作者:Jack47 目前Google Bazel没有提供各个操作系统下的二进制安装包,只提供源代码,需要我们自己编译安装,详情可以见我翻译的中文版Google B ...
- Mediapipe 在RK3399PRO上的初探(一)(编译、运行CPU和GPU Demo, RK OpenglES 填坑,编译bazel)
PS:要转载请注明出处,本人版权所有. PS: 这个只是基于<我自己>的理解, 如果和你的原则及想法相冲突,请谅解,勿喷. 前置说明 本文作为本人csdn blog的主站的备份.(Bl ...
- Ubuntu 环境 TensorFlow (最新版1.4) 源码编译、安装
Ubuntu 环境 TensorFlow 源码编译安装 基于(Ubuntu 14.04LTS/Ubuntu 16.04LTS/) 一.编译环境 1) 安装 pip sudo apt-get insta ...
- 【C++】bazel的使用
bazel的使用 bazel是google开源的构建工具,可以支持多种语言的构建.这里来尝试一下如何在C++项目中使用bazel构建. 安装就不介绍了,在官网很详细,输入bazel --help: U ...
随机推荐
- 2019ICPC南京网络赛A题 The beautiful values of the palace(三维偏序)
2019ICPC南京网络赛A题 The beautiful values of the palace https://nanti.jisuanke.com/t/41298 Here is a squa ...
- javaWeb中的session和cookie
Cookie Cookie 是浏览器提供的一种技术,通过服务器的程序能将一些只须保存在客户端,或者 在客户端进行处理的数据,放在本地的计算机上,不需要通过网络传输,因而提高网页处理的效率,并且能够减少 ...
- solr介绍
solr架构图: 以下是Apache Solr的主要构建块(组件) 请求处理程序 - 发送到Apache Solr的请求由这些请求处理程序处理.请求可以是查询请求或索引更新请求.根据这些请示的要求来选 ...
- 记录weblogic12c通用版本在windowsXP上安装报异常的问题:java.lang.NoClassDefFoundError:
先上图: 这个可能有经验的人一眼就看出问题了,报这个错的原因是:我把安装包放在了中文目录下,本来以为安装包放在中文目录下无关紧要,但是weblogic12c就是这么神奇,不能放在中文目录下. 解决方法 ...
- hive传递参数与调用
在运行hive命令时传入参数,使用-hivevar 和 -hiveconf 两种参数选项,来给此次的执行脚本传入参数 -hivevar : 传参数 ,专门提供给用户自定义变量. -hiveconf : ...
- 配置并访问NFS共享
NFS服务器 192.168.2.5 NFS客户机 192.168.2.100 软件包nfs-utils用来提供NFS共享服务及相关工具,而软件包rpcbind用来提供RPC协议的支持 服务器 修改/ ...
- php文件夹上传
php上传大文件配置 PHP用超级全局变量数组$_FILES来记录文件上传相关信息的. 1.file_uploads=on/off 是否允许通过http方式上传文件 2.max_execution_t ...
- Java中indexOf的用法
indexOf有四种用法: 1.indexOf(int ch) 在给定字符串中查找字符(ASCII),找到返回字符数组所对应的下标找不到返回-1 2.indexOf(String str)在给定符串中 ...
- ngx_http_auth_request_module 第三方认证
shell > vim /usr/local/nginx-1.10.2/conf/vhost/auth.conf # 这是第三方认证服务器,认证逻辑使用的 PHP 代码 server { lis ...
- jQuery事件之解绑事件
语法: $(selector).unbind([eventType][,handler(eventObject)]); 返回值:jQuery 参数解释: eventTypey:类型:String以后包 ...