系统信息: Python:3.6.9 Tensorflow:来自 pip 的 2.2.0 CPU 包
问题:
我从 tf-hub 获取了https://tfhub.dev/google/imagenet/resnet_v2_50/classification/4?tf-hub-format=compressed,然后在新目录中解压缩。
wget https://storage.googleapis.com/tfhub-modules/google/imagenet/resnet_v2_50/feature_vector/4.tar.gz
mkdir test_pb
mv 4.tar.gz test_pb
cd test_pb
tar -xvf 4.tar.gz
rm 4.tar.gz
cd ..
./test.py
Run Code Online (Sandbox Code Playgroud)
https://storage.googleapis.com/tfhub-modules/google/imagenet/resnet_v2_50/feature_vector/4.tar.gz是来自https://tfhub.dev/google/imagenet/resnet_v2_50/的特征向量预训练模型tf-hub 中的feature_vector/4 。
test.py是 Python 脚本,以下是独立代码:
#!/usr/bin/env python3
from __future__ import absolute_import, division, print_function, unicode_literals
import os
import tensorflow as tf
print(tf.__version__)
resnet50v2_save_path = os.path.join('.', "./test_pb/")
loaded1 = tf.keras.models.load_model(resnet50v2_save_path)
print("Load done")
print("Signatures: ", loaded1.signatures)
print("Type: ", type(loaded1))
print(loaded1.summary())
Run Code Online (Sandbox Code Playgroud)
给出这个输出:
2.2.0
2020-06-12 20:29:07.677555: I tensorflow/core/platform/profile_utils/cpu_utils.cc:102] CPU …Run Code Online (Sandbox Code Playgroud) python python-3.x tensorflow tensorflow-datasets tensorflow2.0
我正在尝试编译不使用动态加载器的可执行文件(ELF文件)。我曾经Cython将Python编译为C:
cython3 -3 test.py --embed
Run Code Online (Sandbox Code Playgroud)
然后
gcc test.c -otest $(pkg-config --libs --cflags python3)
Run Code Online (Sandbox Code Playgroud)
编译C生成的文件。
现在,我想test.c在静态可执行文件中进行编译。通常我使用-staticflag,但是在这里return collect2: error: ld returned 1 exit status。
我能怎么做?
编辑1: 不是完整的消息,因为正文限制为30000个字符
一长串如下警告和错误:
...
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libpython3.5m.a(pyexpat.o):(.data+0x430): undefined reference to `XML_SetStartCdataSectionHandler'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libpython3.5m.a(pyexpat.o):(.data+0x458): undefined reference to `XML_SetEndCdataSectionHandler'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libpython3.5m.a(pyexpat.o):(.data+0x480): undefined reference to `XML_SetDefaultHandler'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libpython3.5m.a(pyexpat.o):(.data+0x4a8): undefined reference to `XML_SetDefaultHandlerExpand'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libpython3.5m.a(pyexpat.o):(.data+0x4d0): undefined reference to `XML_SetNotStandaloneHandler'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libpython3.5m.a(pyexpat.o):(.data+0x4f8): undefined reference to `XML_SetExternalEntityRefHandler'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libpython3.5m.a(pyexpat.o):(.data+0x520): undefined reference to `XML_SetStartDoctypeDeclHandler'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libpython3.5m.a(pyexpat.o):(.data+0x548): undefined reference to `XML_SetEndDoctypeDeclHandler'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libpython3.5m.a(pyexpat.o):(.data+0x570): undefined reference to `XML_SetEntityDeclHandler' …Run Code Online (Sandbox Code Playgroud)