Skip to content

Commit e5c0665

Browse files
committed
auto download tensorflow for Windows.
1 parent e72d7ca commit e5c0665

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed

src/TensorFlowNET.Core/Framework/c_api_util.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public static void DownloadLibrary()
4040
{
4141
case PlatformID.Win32NT:
4242
dll = $"{dll}.dll";
43-
file = Path.Combine(directory, "tensorflow.zip");
43+
file = Path.Combine(directory, "libtensorflow-cpu-windows-x86_64-1.14.0.zip");
44+
url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-1.14.0.zip";
4445
break;
4546
case PlatformID.Unix:
4647
dll = $"lib{dll}.so";
@@ -56,7 +57,6 @@ public static void DownloadLibrary()
5657
isDllDownloaded = true;
5758
return;
5859
}
59-
6060

6161
lock (locker)
6262
{
@@ -81,6 +81,9 @@ public static void DownloadLibrary()
8181
{
8282
case PlatformID.Win32NT:
8383
ZipFile.ExtractToDirectory(file, directory);
84+
Util.CmdHelper.Command($"move lib\\* .\\");
85+
Util.CmdHelper.Command($"rm -r lib");
86+
Util.CmdHelper.Command($"rm -r include");
8487
break;
8588
case PlatformID.Unix:
8689
Util.CmdHelper.Bash($"tar xvzf {file} ./lib/");
Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*****************************************************************************
2+
Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
******************************************************************************/
16+
117
using System;
218
using System.Collections.Generic;
319
using System.Diagnostics;
@@ -9,18 +25,30 @@ namespace Tensorflow.Util
925
{
1026
public static class CmdHelper
1127
{
28+
public static void Command(string command)
29+
{
30+
Process proc = new System.Diagnostics.Process();
31+
proc.StartInfo.FileName = @"C:\Windows\System32\cmd.exe";
32+
proc.StartInfo.Arguments = "/c \" " + command + " \"";
33+
proc.StartInfo.UseShellExecute = false;
34+
proc.StartInfo.RedirectStandardOutput = true;
35+
proc.Start();
36+
37+
while (!proc.StandardOutput.EndOfStream)
38+
Console.WriteLine(proc.StandardOutput.ReadLine());
39+
}
40+
1241
public static void Bash(string command)
1342
{
14-
Process proc = new System.Diagnostics.Process ();
43+
Process proc = new System.Diagnostics.Process();
1544
proc.StartInfo.FileName = "/bin/bash";
1645
proc.StartInfo.Arguments = "-c \" " + command + " \"";
17-
proc.StartInfo.UseShellExecute = false;
46+
proc.StartInfo.UseShellExecute = false;
1847
proc.StartInfo.RedirectStandardOutput = true;
19-
proc.Start ();
48+
proc.Start();
2049

21-
while (!proc.StandardOutput.EndOfStream) {
22-
Console.WriteLine (proc.StandardOutput.ReadLine ());
23-
}
50+
while (!proc.StandardOutput.EndOfStream)
51+
Console.WriteLine(proc.StandardOutput.ReadLine());
2452
}
2553
}
2654
}

0 commit comments

Comments
 (0)