使用itorch时无法加载Lib graphviz
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用itorch时无法加载Lib graphviz相关的知识,希望对你有一定的参考价值。
我正在按照火炬队提供的教程学习火炬。当我按照'NNGraph Tutorial'提供的方式键入下面的行时,出乎意料的发生了:
-- it is common style to mark inputs with identity nodes for clarity.
input = nn.Identity()()
-- each hidden layer is achieved by connecting the previous one
-- here we define a single hidden layer network
h1 = nn.Tanh()(nn.Linear(20, 10)(input))
output = nn.Linear(10, 1)(h1)
mlp = nn.gModule({input}, {output})
x = torch.rand(20)
dx = torch.rand(1)
mlp:updateOutput(x)
mlp:updateGradInput(x, dx)
mlp:accGradParameters(x, dx)
-- draw graph (the forward graph, '.fg')
-- this will produce an SVG in the runtime directory
graph.dot(mlp.fg, 'MLP', 'MLP')
itorch.image('MLP.svg')
错误信息:
...s/noahcao/torch/install/share/lua/5.2/graph/graphviz.lua:157: graphviz library could not be loaded.
stack traceback:
/Users/noahcao/torch/install/share/lua/5.2/itorch/main.lua:167: in function </Users/noahcao/torch/install/share/lua/5.2/itorch/main.lua:160>
[C]: in function 'error'
...s/noahcao/torch/install/share/lua/5.2/graph/graphviz.lua:157: in function 'graphvizFile'
...s/noahcao/torch/install/share/lua/5.2/graph/graphviz.lua:197: in function 'dot'
[string "-- it is common style to mark inputs with ide..."]:18: in main chunk
[C]: in function 'xpcall'
/Users/noahcao/torch/install/share/lua/5.2/itorch/main.lua:210: in function </Users/noahcao/torch/install/share/lua/5.2/itorch/main.lua:174>
(...tail calls...)
/Users/noahcao/torch/install/share/lua/5.2/lzmq/poller.lua:75: in function 'poll'
...s/noahcao/torch/install/share/lua/5.2/lzmq/impl/loop.lua:307: in function 'poll'
...s/noahcao/torch/install/share/lua/5.2/lzmq/impl/loop.lua:325: in function 'sleep_ex'
...s/noahcao/torch/install/share/lua/5.2/lzmq/impl/loop.lua:370: in function 'start'
/Users/noahcao/torch/install/share/lua/5.2/itorch/main.lua:389: in main chunk
[C]: in function 'require'
(command line):1: in main chunk
[C]: in ?
但是我检查了graphviz.lua文件,看起来没问题。我无法理解这些信息想告诉我什么。
答案
我也面临同样的问题。这解决了我的问题:
# Mac users
brew install graphviz
# Debian/Ubuntu users
sudo apt-get install graphviz -y
希望这可以帮助某人。
请查看此link以获取Torch的Graph包。
以上是关于使用itorch时无法加载Lib graphviz的主要内容,如果未能解决你的问题,请参考以下文章
pydot 和 graphviz 错误:无法导入 dot_parser,无法加载 dot 文件
Cloud Functions 部署失败:“加载用户代码时函数失败。错误消息:无法加载文件 lib/index.js 中的代码。”
Pygraphviz 安装失败,错误代码 1083 无法打开文件 graphviz/cgraph.h:没有这样的文件或目录