Comments (7)
Could you try adding -lswiftPython
to your command?
If that solves the problem, I'll look into making the REPL link libswiftPython.so
and libswiftTensorFlow.so
by default. Currently, I believe it only links libswiftCore.so
.
from swift.
awesome, I figured this was likely the issue here and probably related to #5 but didn't have time to find the lib names.
This works: swift -I/usr/lib/swift/clang/include -I/usr/src/TFExample/.build/debug -L/usr/src/TFExample/.build/debug -lswiftPython -lTFExample
important to note however that the order in which the flags are supplied matters (the order above is correct, reverse the -l
and it fails) which I guess I didn't expect, but maybe that's just due to how rusty I am with the toolchain right now.
sounds like getting this linking out of the way up front is the solution. also, I haven't built from source yet so I'm not sure on what's captured in current docs, but probably want to note all this for people who roll their own.
from swift.
Thanks for confirming -lswiftPython
works! The solution should just be a matter of adding the flag by default, then.
Can you share what test program you're running? I'd like to replicate the "link flag ordering" issue.
from swift.
Sure, it's the example here but I'll paste it below for ease.
Starting the container with:
docker run --rm --security-opt seccomp:unconfined -itv ${PWD}:/usr/src \
zachgray/swift-tensorflow:4.2 \
swift \
-I/usr/lib/swift/clang/include \
-I/usr/src/TFExample/.build/debug \
-L/usr/src/TFExample/.build/debug \
-lswiftPython \
-lswiftTensorFlow \
-lTFExample
and I can run the following:
1> import RxSwift
2> import Python
3> import TensorFlow
4> var x = Tensor([[1, 2], [3, 4]])
x: TensorFlow.Tensor<Double> = [[1.0, 2.0], [3.0, 4.0]]
5> _ = Observable.from([1,2]).subscribe(onNext: { print($0) })
1
2
6> var x: PyValue = [1, "hello", 3.14]
x: Python.PyValue = [1, 'hello', 3.14]
7> :exit
However, if we change the above run command to:
docker run --rm --security-opt seccomp:unconfined -itv ${PWD}:/usr/src \
zachgray/swift-tensorflow:4.2 \
swift \
-I/usr/lib/swift/clang/include \
-I/usr/src/TFExample/.build/debug \
-L/usr/src/TFExample/.build/debug \
-lTFExample \
-lswiftPython \
-lswiftTensorFlow
the result is as follows:
1> import RxSwift
2> import Python
error: Couldn't lookup symbols:
_swift_FORCE_LOAD_$_swiftPython
and also, the test case and results for #4 are also applicable again with the flags in the wrong order.
from swift.
Thanks for sharing!
That's weird, I don't get the _swift_FORCE_LOAD_$_swiftPython
error:
$ docker run --rm --security-opt seccomp:unconfined -itv ${PWD}:/usr/src \
zachgray/swift-tensorflow:4.2 \
swift \
-I/usr/lib/swift/clang/include \
-I/usr/src/TFExample/.build/debug \
-L/usr/src/TFExample/.build/debug \
-lTFExample \
-lswiftPython \
-lswiftTensorFlow
Welcome to Swift version 4.2-dev (LLVM 04bdb56f3d, Clang b44dbbdf44). Type :help for assistance.
1> import RxSwift
2> import Python
3> PyValue([1, "hello", 3.14])
$R0: Python.PyValue = [1, 'hello', 3.14]
From my observations, there are some other factors affecting the REPL and linking. Sometimes, commands that don't initially work magically work after I run commands that do link libraries correctly. The interpreter/compiler seem to have more predictable behavior.
In any case, I'm looking into a fix for the REPL!
from swift.
Actually, this confirms what I saw once or twice myself but hadn't brought up yet. The REPL does behave incosistently. The really strange part is that the linker flags passed in a specific order seems to work more predictably.
from swift.
Sorry for the delay! I believe this is fixed in 1969380.
You can try the pre-built packages from 05-10 to verify.
Verifying the fix was a bit difficult because the REPL doesn't seem to fail consistently.
I made sure that the Couldn't lookup symbols
error didn't occur to me anymore for the commands listed above involving the TFExample
library.
It's fully possible that linking more libraries causes other issues. If you find any, please file a new issue and I'll take a look. 😄
from swift.
Related Issues (20)
- Close all open issues and pull requests since this repository has been moved
- Python linking in xcode HOT 5
- Internal error when `public`s are removed from the catch model HOT 3
- Configuring swift-format's line breaking rule
- Add build instructions to Readme
- Error building swift-format HOT 1
- Translation of Google Swift Style Guide
- Unexpected newline before opening brace for method calls with trailing closures
- The rule NoAccessLevelOnExtensionDeclaration doesn't work
- testEagerLoop() in crashers.swift crashers in TFLowerGraph.cpp, after supporting TF tensor receives HOT 1
- Use SILPrinter callback mechanism to annotate the printed SIL code HOT 2
- Bridge Python `numpy.ndarray` to `Array` and `Tensor` HOT 2
- Crash when doing basic Swift's String Interpolation. HOT 10
- [Ubuntu] `Python.import("numpy")` fails in the REPL HOT 5
- Non-data dependent code with side effects - should they sync? HOT 8
- Implement UseOnlySpaces HOT 1
- Implement UseTripleSlashForDocumentationComments HOT 1
- implement NeverUseForceTry HOT 1
- Implement NeverUseImplicitlyUnwrappedOptionals HOT 1
- Implement CyclomaticComplexityWarning.swift HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift.