去演示示例运行的TensorFlow失败 [英] TensorFlow for Go demo example run failed

查看:204
本文介绍了去演示示例运行的TensorFlow失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



环境


  macbookpro:lib fredlee $ go版本
go版本go1.8.3 darwin / amd64
macbookpro:lib fredlee $ pwd
/ usr / local / lib
macbookpro: lib fredlee $ ls -alh libtensorflow.so
-r-xr-xr-x 1根轮子102M 1 1 1970 libtensorflow.so
macbookpro:lib fredlee $文件libtensorflow.so
libtensorflow。因此:Mach-O 64位动态链接共享库x86_64
macbookpro:lib fredlee $


问题

 > macbookpro:〜fredlee $ go获得
> github.com/tensorflow/tensorflow/tensorflow/go macbookpro:〜fredlee $
> go test github.com/tensorflow/tensorflow/tensorflow/go
> #github.com/tensorflow/tensorflow/tensorflow/go ld:找不到-ltensorflow clang的库:错误:linker命令失败,退出代码1
> (使用-v来查看调用)
> FAIL github.com/tensorflow/tensorflow/tensorflow/go [build failed]

任何人都可以帮我制作它的工作原理是什么?

解决方案

错误非常明显:


ld:找不到-ltensorflow库

当您运行 go test code>您正在调用编译器来编译所需的库,测试文件,然后执行它们。



当您编译一个使用非纯粹的库,你必须让编译器(和链接器)知道库。



在编译阶段,编译器查找库( )在OS X和OS X上列出的路径中:



LIBRARY_PATH Linux。



因此,你必须在这个变量中加入已编译库的位置。



例如I有:

  TFGOLIB =$ {GOPATH} /src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow 
export LIBRARY_PATH =$ {TFGOLIB}:$ {LIBRARY_PATH}

,而是为了执行动态链接,os会查找库。



因此,您必须设置其他变量( LD_LIBRARY_PATH 在Linux和 DYLD_LIBRARY_PATH 在OS X)到同一个位置。



此外,我建议你

  export LD_LIBRARY_PATH =$ LD_LIBRARY_PATH: /opt/cuda/lib64:/opt/cuda/extras/CUPTI/lib64:/opt/cudnn5.1/cuda/lib64:${TFGOLIB}


i have the issue.

environment

macbookpro:lib fredlee$ go version
go version go1.8.3 darwin/amd64
macbookpro:lib fredlee$ pwd
/usr/local/lib
macbookpro:lib fredlee$ ls -alh libtensorflow.so 
-r-xr-xr-x  1 root  wheel   102M  1  1  1970 libtensorflow.so
macbookpro:lib fredlee$ file libtensorflow.so 
libtensorflow.so: Mach-O 64-bit dynamically linked shared library x86_64
macbookpro:lib fredlee$

issue

> macbookpro:~ fredlee$ go get
> github.com/tensorflow/tensorflow/tensorflow/go macbookpro:~ fredlee$
> go test github.com/tensorflow/tensorflow/tensorflow/go
> # github.com/tensorflow/tensorflow/tensorflow/go ld: library not found for -ltensorflow clang: error: linker command failed with exit code 1
> (use -v to see invocation)
> FAIL  github.com/tensorflow/tensorflow/tensorflow/go [build failed]

anyone can help me make it works?

解决方案

The error is pretty clear:

ld: library not found for -ltensorflow

When you run go test you're invoking the go compiler that compiles the required libraries, your test files and then executes them.

When you compile a program that uses a "non-pure" go library, you have to make the compiler (and the linker) aware of the library.

In the compilation phase, the compiler looks for the libraries (also) in the paths listed into the environment variable:

LIBRARY_PATH on OS X & Linux.

Thus you have to add into this variable the location of the compiled library.

For example I have:

TFGOLIB="${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow"
export LIBRARY_PATH="${TFGOLIB}:${LIBRARY_PATH}"

During the runtime, instead, the os looks for the library in order to perform dynamic linking.

Thus you have to set this other variable (LD_LIBRARY_PATH on Linux and DYLD_LIBRARY_PATH on OS X) to the same location.

Moreover I suggest you to also add the CUDA library path to this variable, in order to make it available at runtime.

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/cuda/lib64:/opt/cuda/extras/CUPTI/lib64:/opt/cudnn5.1/cuda/lib64:${TFGOLIB}"

这篇关于去演示示例运行的TensorFlow失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆