doudou2121 2019-07-18 14:02 采纳率: 50%
浏览 2079

libtensorflow.so:无法打开共享库文件:没有这样的文件或目录

我使用以下命令创建了AWS Lambda层:

aws lambda publish-layer-version --layer-name TensorflowLambdaLayer --compatible-runtimes go1.x --zip-file fileb://tensorflowLayer.zip

下面是生成的ARN: `arn:aws:lambda:us-east-1:757767972066:layer:TensorflowLambdaLayer:1

当我试图通过 AWS SAM 运行使用 Tesnroflow 库的 Lambda 函数时,它被卡在了“挂载”步骤:

2019-07-18 15:51:29 Mounting /tmp/tmpgz8cb80s as /var/task:ro,delegated inside runtime container

一旦我用 Ctrl + c 终止它,我会得到如下信息:

^C/var/task/bin/inference: error while loading shared libraries: libtensorflow.so: cannot open shared object file: No such file or directory
Makefile:82: recipe for target 'run-inference' failed

下面是我的 template.yml 的关键部分:

Parameters:
  LambdaTensorflowLayerArn:
    Type: String
    Default: 'arn:aws:lambda:us-east-1:757767972066:layer:TensorflowLambdaLayer:1'
  LambdaFFMPEGLayerArn:
    Type: String
    Default: 'arn:aws:lambda:us-east-1:757767972066:layer:ffmpeg:1'

Inference:
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: bin/inference
      Runtime: go1.x
      Timeout: 300
      CodeUri: ./bin/inference.zip
      Layers: 
         - Ref: LambdaFFMPEGLayerArn
         - Ref: LambdaTensorflowLayerArn

我不确定是什么导致了这种情况。

  • 写回答

1条回答 默认 最新

  • duanbi7247 2019-07-23 03:59
    关注

    I was having the same issue with the message

    error while loading shared libraries: libtensorflow.so.1: cannot open shared object file: No such file or directory

    In my case, it was trying to use TensorFlow with go. The problem is that the official installation for libtensorflow.so (and libtensorflow_framework.so) doesn't seem to be working if the package is left in /usr/local (recommended) or in other path. Using ldconfig as suggested for /usr/local doesn't help either. Also, the base example for gcc doesn't work (even with the -L. This has surprised me) until the LD_LIBRARY_PATH is set:

     $ gcc -I/usr/local/include -L/usr/local/lib hello_tf.c -ltensorflow -o hello_tf
     $ ./hello_tf 
     ./hello_tf: error while loading shared libraries: libtensorflow.so.1: cannot open shared object file: No such file or directory
     $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
     $ ./hello_tf 
     Hello from TensorFlow C library version 1.14.0
     $ unset LD_LIBRARY_PATH 
     $ ./hello_tf 
     ./hello_tf: error while loading shared libraries: libtensorflow.so.1: cannot open shared object file: No such file or directory
    

    This is the content of /usr/local in my case

     $ ll /usr/local/lib
     total 245424
     lrwxrwxrwx. 1 root root        28 dic 31  1999 libtensorflow_framework.so -> libtensorflow_framework.so.1
     lrwxrwxrwx. 1 root root        33 dic 31  1999 libtensorflow_framework.so.1 -> libtensorflow_framework.so.1.14.0
     -r-xr-xr-x. 1 root root  34748520 dic 31  1999 libtensorflow_framework.so.1.14.0
     lrwxrwxrwx. 1 root root        18 dic 31  1999 libtensorflow.so -> libtensorflow.so.1
     lrwxrwxrwx. 1 root root        23 dic 31  1999 libtensorflow.so.1 -> libtensorflow.so.1.14.0
     -r-xr-xr-x. 1 root root 216546752 dic 31  1999 libtensorflow.so.1.14.0
    

    The other solution was to manually create the symlinks to /usr/lib. I don't know how to do that in a serverless config. Was going to write this in a comment but still dont have enough rep.

    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型