Skip to content

Commit 5c7db1e

Browse files
committed
Got things to compile on Windows.
1 parent 7f5b045 commit 5c7db1e

File tree

7 files changed

+19
-11
lines changed

7 files changed

+19
-11
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ project/plugins/project/
2121

2222
# Bloop Specific
2323
.bloop
24+
.bsp
2425

2526
# Metals Specific
2627
.metals

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ command:
207207
sbt jni/cross:nativeCrossCompile
208208
```
209209

210+
CUDA Compute Capabilities: 3.5,7.0,7.5,8.0,8.6
211+
210212
Compile the TensorFlow dynamic libraries from source using:
211213

212214
```bash

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ lazy val jni = (project in file("./modules/jni"))
170170
sourceDirectory in nativeCompile := sourceDirectory.value / "main" / "native",
171171
target in nativeCompile := target.value / "native" / nativePlatform.value,
172172
target in JniCross := target.value / "native",
173-
nativePlatforms in JniCross := Set(LINUX, WINDOWS_CPU, WINDOWS_GPU, DARWIN),
173+
nativePlatforms in JniCross := Set(LINUX, WINDOWS, WINDOWS_CPU, DARWIN),
174174
tfBinaryVersion in JniCross := tensorFlowVersion,
175175
// Specify the order in which the different compilation tasks are executed.
176176
nativeCompile := nativeCompile.dependsOn(generateTensorOps).value,

modules/jni/src/main/native/ops/beam_search_ops.cc

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ limitations under the License.
2828
#include "tensorflow/core/framework/shape_inference.h"
2929
#include "tensorflow/core/util/work_sharder.h"
3030

31+
// Hack to fix compilation on Windows.
32+
#define EXPAND(x) x
33+
#define TF_NEW_ID_FOR_INIT_2(m, c, ...) EXPAND(m(c, __VA_ARGS__)) // L145 selective_registration.h
34+
#define TF_EXTRACT_KERNEL_NAME_IMPL(m, ...) EXPAND(m(__VA_ARGS__)) // L1431 op_kernel.h
35+
3136
namespace tensorflow {
3237

3338
using shape_inference::DimensionHandle;

modules/jni/src/main/scala/org/platanios/tensorflow/jni/TensorFlow.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object TensorFlow {
5656
val name = System.getProperty("os.name").toLowerCase
5757
if (name.contains("linux")) "linux"
5858
else if (name.contains("os x") || name.contains("darwin")) "darwin"
59-
else if (name.contains("windows")) "windows-cpu"
59+
else if (name.contains("windows")) "windows"
6060
else name.replaceAll("\\s", "")
6161
}
6262

project/JniCrossPackage.scala

+7-7
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ object JniCrossPackage extends AutoPlugin {
5959
import JniNative.autoImport._
6060

6161
lazy val settings: Seq[Setting[_]] = Seq(
62-
nativePlatforms := Set(LINUX, WINDOWS_CPU, WINDOWS_GPU, DARWIN),
62+
nativePlatforms := Set(LINUX, WINDOWS, WINDOWS_CPU, DARWIN),
6363
target := (target in Compile).value / "native",
6464
nativeLibPath := {
6565
val targetDir = (target in nativeCrossCompile).value
@@ -106,7 +106,7 @@ object JniCrossPackage extends AutoPlugin {
106106
// TODO: Figure out the right cross-compilation story.
107107
// For Windows, we expect the binaries to have already been built and placed in the `bin` and the `lib`
108108
// subdirectories, because we currently have no way to cross-compile.
109-
case WINDOWS_CPU | WINDOWS_GPU =>
109+
case WINDOWS | WINDOWS_CPU =>
110110
if (!(platformTargetDir / "bin").exists()) {
111111
throw new IllegalStateException("The Windows binaries must have already been prebuilt.")
112112
}
@@ -255,15 +255,15 @@ object JniCrossPackage extends AutoPlugin {
255255

256256
object LINUX extends Platform {
257257
override val name : String = "linux"
258-
override val dockerImage: String = "eaplatanios/tensorflow_scala:linux-cpu-x86_64-0.5.3"
258+
override val dockerImage: String = "eaplatanios/tensorflow_scala:linux-cpu-x86_64-0.6.0"
259259
}
260260

261-
object WINDOWS_CPU extends Platform {
262-
override val name: String = "windows-cpu"
261+
object WINDOWS extends Platform {
262+
override val name: String = "windows"
263263
}
264264

265-
object WINDOWS_GPU extends Platform {
266-
override val name: String = "windows-gpu"
265+
object WINDOWS_CPU extends Platform {
266+
override val name: String = "windows-cpu"
267267
}
268268

269269
object DARWIN extends Platform {

project/TensorFlowNativePackage.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ object TensorFlowNativePackage extends AutoPlugin {
6767

6868
def tfLibFilename(platform: Platform): String = platform match {
6969
case LINUX | DARWIN => "libtensorflow.tar.gz"
70-
case WINDOWS_CPU | WINDOWS_GPU => "libtensorflow.zip"
70+
case WINDOWS | WINDOWS_CPU => "libtensorflow.zip"
7171
}
7272

7373
def tfLibUrl(platform: Platform, version: String): String = (platform, version) match {
7474
case (LINUX, v) => s"$tfLibUrlPrefix-gpu-linux-x86_64-$v.tar.gz"
75+
case (WINDOWS, v) => s"$tfLibUrlPrefix-gpu-windows-x86_64-$v.zip"
7576
case (WINDOWS_CPU, v) => s"$tfLibUrlPrefix-cpu-windows-x86_64-$v.zip"
76-
case (WINDOWS_GPU, v) => s"$tfLibUrlPrefix-gpu-windows-x86_64-$v.zip"
7777
case (DARWIN, v) => s"$tfLibUrlPrefix-cpu-darwin-x86_64-$v.tar.gz"
7878
}
7979

0 commit comments

Comments
 (0)