Install rsut-tensorflow from a prebuild binary (windows)

34 views
Skip to first unread message

Maxime Girard

unread,
May 11, 2020, 11:08:50 AM5/11/20
to Rust for TensorFlow
Hey,

I successfully build Tensorflow v2.1.0 (v2.2.0 fail) on my Windows.
I install python pip package to test if python detect correctly the gpu support and all is fine.

I want to use this manual build from Rust.

I begin Rust a few days ago so I'm not so familiar with the package config mecanism and how Rust deal with dependancy.

I don't find a good explanation to tell to Rust to use my libtensorflow.so and libtensorflow_framework.so that I just build.




I begin block at the end when we have to generate tensorflow.pc. I sucess to generate it (but I'm pretty sure that the value in there is wrong but anyway) but I don't know what I have to do with it ?


On me rust program, I wrote in Cargo.toml :

tensorflow-sys = { version = "0.18.0", features = ["tensorflow_gpu"] }

I have a second question about that : In the main page ( https://github.com/tensorflow/rust ) they wrote that we have to use :
tensorflow = { version = "0.15.0", features = ["tensorflow_gpu"] }.

So does we have to wrote the two lines ?
Ie :

tensorflow-sys = { version = "0.18.0", features = ["tensorflow_gpu"] }
tensorflow = { version = "0.15.0", features = ["tensorflow_gpu"] }


Can you help me ?

Thx.

Adam Crume

unread,
May 13, 2020, 1:10:48 PM5/13/20
to Maxime Girard, Rust for TensorFlow
Unless you want to call the C API directly, you probably don't want to use the tensorflow-sys crate and should just use the tensorflow crate instead, which uses tensorflow-sys under the hood.  The TensorFlow 2 branch is not yet supported, so I suggest sticking to TensorFlow 1.

You have three options for linking in TensorFlow:
1. Support for downloading prebuilt Windows binaries was only very recently added (https://github.com/tensorflow/rust/pull/250) and is not yet released, so you would need to manually check out the source for the tensorflow and tensorflow-sys crates and specify a path dependency (https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-path-dependencies) if you want to do that.
2. You can let the tensorflow crate build TensorFlow from source, which should be the default in the current Windows version.
3. If you want to build your own TensorFlow library and use that, I think you need the tensorflow.lib file on your PATH.  I'm not an expert on Windows, though, so I'd love if one of our Windows users could chime in to help.

--
You received this message because you are subscribed to the Google Groups "Rust for TensorFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rust+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/rust/7f2aba15-b9ba-4342-b78f-ddf87d5627a6%40tensorflow.org.

Maxime Girard

unread,
May 13, 2020, 5:53:04 PM5/13/20
to Rust for TensorFlow, maxime.g...@gmail.com
Thx Adam !

I just success by my own two days ago by linking properly from rust into tensorflow and execute a simple example and that's work perfectly !

From what you said, effectivly I need the .lib but the actual state of the script don't generate it. I patch the bazel script by adding this : https://github.com/Potoman/Snake/blob/master/patch_to_generate_tensorflow_framework_lib.patch

After this patch, I build tensorflow_framework.lib and, by settings pkg_config (which I never use before this topic), I correctly binding on tensorflow and I'm very happy.

Thx for you help and thx for the explanation about tensorflow-sy, I remove it to made the things going well.

Futhermore, I staty in 2.1. The tag 2.2 doesn't compile on my Windows (MSVC 2019 or 2017) even by following with a good accuracy the step. But this is ok. I test on the master HEAD another time.

++

Maxime.
Reply all
Reply to author
Forward
0 new messages